/*
 * Copyright (C) 2007-2018 Siemens AG
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

/*******************************************************************
 *
 * @author Daniel.Peintner.EXT@siemens.com
 * @version 0.9.4 
 * @contact Richard.Kuntschke@siemens.com
 *
 * <p>Code generated by EXIdizer</p>
 * <p>Schema: V2G_CI_MsgDef.xsd</p>
 *
 *
 ********************************************************************/




#include "iso1EXIDatatypesEncoder.h"

#include "EncoderChannel.h"
#include "EXIHeaderEncoder.h"

#include "iso1EXIDatatypes.h"
#include "ErrorCodes.h"

#ifndef EXI_iso1_DATATYPES_ENCODER_C
#define EXI_iso1_DATATYPES_ENCODER_C

#if DEPLOY_ISO1_CODEC == SUPPORT_YES

static int errn;

/* Forward Declarations */
static int encode_iso1MessageHeaderType(bitstream_t* stream, struct iso1MessageHeaderType* iso1MessageHeaderType);
static int encode_iso1SignatureType(bitstream_t* stream, struct iso1SignatureType* iso1SignatureType);
static int encode_iso1PowerDeliveryReqType(bitstream_t* stream, struct iso1PowerDeliveryReqType* iso1PowerDeliveryReqType);
static int encode_iso1ParameterType(bitstream_t* stream, struct iso1ParameterType* iso1ParameterType);
static int encode_iso1CertificateInstallationReqType(bitstream_t* stream, struct iso1CertificateInstallationReqType* iso1CertificateInstallationReqType);
static int encode_iso1SessionSetupResType(bitstream_t* stream, struct iso1SessionSetupResType* iso1SessionSetupResType);
static int encode_iso1EVChargeParameterType(bitstream_t* stream, struct iso1EVChargeParameterType* iso1EVChargeParameterType);
static int encode_iso1DiffieHellmanPublickeyType(bitstream_t* stream, struct iso1DiffieHellmanPublickeyType* iso1DiffieHellmanPublickeyType);
static int encode_iso1ServiceDiscoveryResType(bitstream_t* stream, struct iso1ServiceDiscoveryResType* iso1ServiceDiscoveryResType);
static int encode_iso1ServiceParameterListType(bitstream_t* stream, struct iso1ServiceParameterListType* iso1ServiceParameterListType);
static int encode_iso1CertificateChainType(bitstream_t* stream, struct iso1CertificateChainType* iso1CertificateChainType);
static int encode_iso1SASchedulesType(bitstream_t* stream, struct iso1SASchedulesType* iso1SASchedulesType);
static int encode_iso1DC_EVSEStatusType(bitstream_t* stream, struct iso1DC_EVSEStatusType* iso1DC_EVSEStatusType);
static int encode_iso1PreChargeResType(bitstream_t* stream, struct iso1PreChargeResType* iso1PreChargeResType);
static int encode_iso1ParameterSetType(bitstream_t* stream, struct iso1ParameterSetType* iso1ParameterSetType);
static int encode_iso1ServiceDetailReqType(bitstream_t* stream, struct iso1ServiceDetailReqType* iso1ServiceDetailReqType);
static int encode_iso1RelativeTimeIntervalType(bitstream_t* stream, struct iso1RelativeTimeIntervalType* iso1RelativeTimeIntervalType);
static int encode_iso1SignedInfoType(bitstream_t* stream, struct iso1SignedInfoType* iso1SignedInfoType);
static int encode_iso1EMAIDType(bitstream_t* stream, struct iso1EMAIDType* iso1EMAIDType);
static int encode_iso1EVStatusType(bitstream_t* stream, struct iso1EVStatusType* iso1EVStatusType);
static int encode_iso1ServiceListType(bitstream_t* stream, struct iso1ServiceListType* iso1ServiceListType);
static int encode_iso1EVSEChargeParameterType(bitstream_t* stream, struct iso1EVSEChargeParameterType* iso1EVSEChargeParameterType);
static int encode_iso1EVPowerDeliveryParameterType(bitstream_t* stream, struct iso1EVPowerDeliveryParameterType* iso1EVPowerDeliveryParameterType);
static int encode_iso1ProfileEntryType(bitstream_t* stream, struct iso1ProfileEntryType* iso1ProfileEntryType);
static int encode_iso1AuthorizationReqType(bitstream_t* stream, struct iso1AuthorizationReqType* iso1AuthorizationReqType);
static int encode_iso1MeterInfoType(bitstream_t* stream, struct iso1MeterInfoType* iso1MeterInfoType);
static int encode_iso1ManifestType(bitstream_t* stream, struct iso1ManifestType* iso1ManifestType);
static int encode_iso1ChargeParameterDiscoveryResType(bitstream_t* stream, struct iso1ChargeParameterDiscoveryResType* iso1ChargeParameterDiscoveryResType);
static int encode_iso1PowerDeliveryResType(bitstream_t* stream, struct iso1PowerDeliveryResType* iso1PowerDeliveryResType);
static int encode_iso1DC_EVChargeParameterType(bitstream_t* stream, struct iso1DC_EVChargeParameterType* iso1DC_EVChargeParameterType);
static int encode_iso1ConsumptionCostType(bitstream_t* stream, struct iso1ConsumptionCostType* iso1ConsumptionCostType);
static int encode_iso1PMaxScheduleType(bitstream_t* stream, struct iso1PMaxScheduleType* iso1PMaxScheduleType);
static int encode_iso1PaymentOptionListType(bitstream_t* stream, struct iso1PaymentOptionListType* iso1PaymentOptionListType);
static int encode_iso1ObjectType(bitstream_t* stream, struct iso1ObjectType* iso1ObjectType);
static int encode_iso1PhysicalValueType(bitstream_t* stream, struct iso1PhysicalValueType* iso1PhysicalValueType);
static int encode_iso1RSAKeyValueType(bitstream_t* stream, struct iso1RSAKeyValueType* iso1RSAKeyValueType);
static int encode_iso1SessionStopResType(bitstream_t* stream, struct iso1SessionStopResType* iso1SessionStopResType);
static int encode_iso1CertificateUpdateReqType(bitstream_t* stream, struct iso1CertificateUpdateReqType* iso1CertificateUpdateReqType);
static int encode_iso1SignatureValueType(bitstream_t* stream, struct iso1SignatureValueType* iso1SignatureValueType);
static int encode_iso1PaymentDetailsReqType(bitstream_t* stream, struct iso1PaymentDetailsReqType* iso1PaymentDetailsReqType);
static int encode_iso1AuthorizationResType(bitstream_t* stream, struct iso1AuthorizationResType* iso1AuthorizationResType);
static int encode_iso1DC_EVSEChargeParameterType(bitstream_t* stream, struct iso1DC_EVSEChargeParameterType* iso1DC_EVSEChargeParameterType);
static int encode_iso1SubCertificatesType(bitstream_t* stream, struct iso1SubCertificatesType* iso1SubCertificatesType);
static int encode_iso1ChargingStatusResType(bitstream_t* stream, struct iso1ChargingStatusResType* iso1ChargingStatusResType);
static int encode_iso1DSAKeyValueType(bitstream_t* stream, struct iso1DSAKeyValueType* iso1DSAKeyValueType);
static int encode_iso1ListOfRootCertificateIDsType(bitstream_t* stream, struct iso1ListOfRootCertificateIDsType* iso1ListOfRootCertificateIDsType);
static int encode_iso1ChargeServiceType(bitstream_t* stream, struct iso1ChargeServiceType* iso1ChargeServiceType);
static int encode_iso1IntervalType(bitstream_t* stream, struct iso1IntervalType* iso1IntervalType);
static int encode_iso1MeteringReceiptReqType(bitstream_t* stream, struct iso1MeteringReceiptReqType* iso1MeteringReceiptReqType);
static int encode_iso1ServiceDetailResType(bitstream_t* stream, struct iso1ServiceDetailResType* iso1ServiceDetailResType);
static int encode_iso1KeyValueType(bitstream_t* stream, struct iso1KeyValueType* iso1KeyValueType);
static int encode_iso1SelectedServiceListType(bitstream_t* stream, struct iso1SelectedServiceListType* iso1SelectedServiceListType);
static int encode_iso1CableCheckResType(bitstream_t* stream, struct iso1CableCheckResType* iso1CableCheckResType);
static int encode_iso1X509IssuerSerialType(bitstream_t* stream, struct iso1X509IssuerSerialType* iso1X509IssuerSerialType);
static int encode_iso1KeyInfoType(bitstream_t* stream, struct iso1KeyInfoType* iso1KeyInfoType);
static int encode_iso1TransformsType(bitstream_t* stream, struct iso1TransformsType* iso1TransformsType);
static int encode_iso1ChargeParameterDiscoveryReqType(bitstream_t* stream, struct iso1ChargeParameterDiscoveryReqType* iso1ChargeParameterDiscoveryReqType);
static int encode_iso1PreChargeReqType(bitstream_t* stream, struct iso1PreChargeReqType* iso1PreChargeReqType);
static int encode_iso1EVSEStatusType(bitstream_t* stream, struct iso1EVSEStatusType* iso1EVSEStatusType);
static int encode_iso1SignatureMethodType(bitstream_t* stream, struct iso1SignatureMethodType* iso1SignatureMethodType);
static int encode_iso1X509DataType(bitstream_t* stream, struct iso1X509DataType* iso1X509DataType);
static int encode_iso1NotificationType(bitstream_t* stream, struct iso1NotificationType* iso1NotificationType);
static int encode_iso1SAScheduleListType(bitstream_t* stream, struct iso1SAScheduleListType* iso1SAScheduleListType);
static int encode_iso1BodyType(bitstream_t* stream, struct iso1BodyType* iso1BodyType);
static int encode_iso1ChargingProfileType(bitstream_t* stream, struct iso1ChargingProfileType* iso1ChargingProfileType);
static int encode_iso1TransformType(bitstream_t* stream, struct iso1TransformType* iso1TransformType);
static int encode_iso1SAScheduleTupleType(bitstream_t* stream, struct iso1SAScheduleTupleType* iso1SAScheduleTupleType);
static int encode_iso1AC_EVChargeParameterType(bitstream_t* stream, struct iso1AC_EVChargeParameterType* iso1AC_EVChargeParameterType);
static int encode_iso1AnonType_V2G_Message(bitstream_t* stream, struct iso1AnonType_V2G_Message* iso1AnonType_V2G_Message);
static int encode_iso1PaymentDetailsResType(bitstream_t* stream, struct iso1PaymentDetailsResType* iso1PaymentDetailsResType);
static int encode_iso1ContractSignatureEncryptedPrivateKeyType(bitstream_t* stream, struct iso1ContractSignatureEncryptedPrivateKeyType* iso1ContractSignatureEncryptedPrivateKeyType);
static int encode_iso1PMaxScheduleEntryType(bitstream_t* stream, struct iso1PMaxScheduleEntryType* iso1PMaxScheduleEntryType);
static int encode_iso1SPKIDataType(bitstream_t* stream, struct iso1SPKIDataType* iso1SPKIDataType);
static int encode_iso1MeteringReceiptResType(bitstream_t* stream, struct iso1MeteringReceiptResType* iso1MeteringReceiptResType);
static int encode_iso1SessionStopReqType(bitstream_t* stream, struct iso1SessionStopReqType* iso1SessionStopReqType);
static int encode_iso1WeldingDetectionResType(bitstream_t* stream, struct iso1WeldingDetectionResType* iso1WeldingDetectionResType);
static int encode_iso1ReferenceType(bitstream_t* stream, struct iso1ReferenceType* iso1ReferenceType);
static int encode_iso1CurrentDemandReqType(bitstream_t* stream, struct iso1CurrentDemandReqType* iso1CurrentDemandReqType);
static int encode_iso1SalesTariffEntryType(bitstream_t* stream, struct iso1SalesTariffEntryType* iso1SalesTariffEntryType);
static int encode_iso1EntryType(bitstream_t* stream, struct iso1EntryType* iso1EntryType);
static int encode_iso1SessionSetupReqType(bitstream_t* stream, struct iso1SessionSetupReqType* iso1SessionSetupReqType);
static int encode_iso1CostType(bitstream_t* stream, struct iso1CostType* iso1CostType);
static int encode_iso1DC_EVPowerDeliveryParameterType(bitstream_t* stream, struct iso1DC_EVPowerDeliveryParameterType* iso1DC_EVPowerDeliveryParameterType);
static int encode_iso1RetrievalMethodType(bitstream_t* stream, struct iso1RetrievalMethodType* iso1RetrievalMethodType);
static int encode_iso1CertificateUpdateResType(bitstream_t* stream, struct iso1CertificateUpdateResType* iso1CertificateUpdateResType);
static int encode_iso1CertificateInstallationResType(bitstream_t* stream, struct iso1CertificateInstallationResType* iso1CertificateInstallationResType);
static int encode_iso1CanonicalizationMethodType(bitstream_t* stream, struct iso1CanonicalizationMethodType* iso1CanonicalizationMethodType);
static int encode_iso1WeldingDetectionReqType(bitstream_t* stream, struct iso1WeldingDetectionReqType* iso1WeldingDetectionReqType);
static int encode_iso1DC_EVStatusType(bitstream_t* stream, struct iso1DC_EVStatusType* iso1DC_EVStatusType);
static int encode_iso1CurrentDemandResType(bitstream_t* stream, struct iso1CurrentDemandResType* iso1CurrentDemandResType);
static int encode_iso1ServiceType(bitstream_t* stream, struct iso1ServiceType* iso1ServiceType);
static int encode_iso1ServiceDiscoveryReqType(bitstream_t* stream, struct iso1ServiceDiscoveryReqType* iso1ServiceDiscoveryReqType);
static int encode_iso1AC_EVSEChargeParameterType(bitstream_t* stream, struct iso1AC_EVSEChargeParameterType* iso1AC_EVSEChargeParameterType);
static int encode_iso1CableCheckReqType(bitstream_t* stream, struct iso1CableCheckReqType* iso1CableCheckReqType);
static int encode_iso1SelectedServiceType(bitstream_t* stream, struct iso1SelectedServiceType* iso1SelectedServiceType);
static int encode_iso1AC_EVSEStatusType(bitstream_t* stream, struct iso1AC_EVSEStatusType* iso1AC_EVSEStatusType);
static int encode_iso1SalesTariffType(bitstream_t* stream, struct iso1SalesTariffType* iso1SalesTariffType);
static int encode_iso1PaymentServiceSelectionReqType(bitstream_t* stream, struct iso1PaymentServiceSelectionReqType* iso1PaymentServiceSelectionReqType);
static int encode_iso1SignaturePropertiesType(bitstream_t* stream, struct iso1SignaturePropertiesType* iso1SignaturePropertiesType);
static int encode_iso1BodyBaseType(bitstream_t* stream, struct iso1BodyBaseType* iso1BodyBaseType);
static int encode_iso1SupportedEnergyTransferModeType(bitstream_t* stream, struct iso1SupportedEnergyTransferModeType* iso1SupportedEnergyTransferModeType);
static int encode_iso1ChargingStatusReqType(bitstream_t* stream, struct iso1ChargingStatusReqType* iso1ChargingStatusReqType);
static int encode_iso1PaymentServiceSelectionResType(bitstream_t* stream, struct iso1PaymentServiceSelectionResType* iso1PaymentServiceSelectionResType);
static int encode_iso1DigestMethodType(bitstream_t* stream, struct iso1DigestMethodType* iso1DigestMethodType);
static int encode_iso1SignaturePropertyType(bitstream_t* stream, struct iso1SignaturePropertyType* iso1SignaturePropertyType);
static int encode_iso1PGPDataType(bitstream_t* stream, struct iso1PGPDataType* iso1PGPDataType);


/* Complex type name='urn:iso:15118:2:2013:MsgHeader,MessageHeaderType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgHeader":SessionID,"urn:iso:15118:2:2013:MsgHeader":Notification{0-1},"http://www.w3.org/2000/09/xmldsig#":Signature{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_iso1MessageHeaderType(bitstream_t* stream, struct iso1MessageHeaderType* iso1MessageHeaderType) {
	int grammarID = 0;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 0:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgHeader}SessionID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_HEX]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1MessageHeaderType->SessionID.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1MessageHeaderType->SessionID.bytes, iso1MessageHeaderType->SessionID.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 1;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 1:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgHeader}Notification), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Signature), END_ELEMENT] */
			if ( iso1MessageHeaderType->Notification_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1NotificationType(stream, &iso1MessageHeaderType->Notification );
				}
				grammarID = 2;
			} else 			if ( iso1MessageHeaderType->Signature_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1SignatureType(stream, &iso1MessageHeaderType->Signature );
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 2:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Signature), END_ELEMENT] */
			if ( iso1MessageHeaderType->Signature_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SignatureType(stream, &iso1MessageHeaderType->Signature );
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,SignatureType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":SignedInfo,"http://www.w3.org/2000/09/xmldsig#":SignatureValue,"http://www.w3.org/2000/09/xmldsig#":KeyInfo{0-1},"http://www.w3.org/2000/09/xmldsig#":Object{0-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_iso1SignatureType(bitstream_t* stream, struct iso1SignatureType* iso1SignatureType) {
	int grammarID = 5;
	int done = 0;
	
	unsigned int iso1SignatureType_Object_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 5:
			/* FirstStartTag[ATTRIBUTE[STRING](Id), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignedInfo)] */
			if ( iso1SignatureType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SignatureType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1SignatureType->Id.characters, iso1SignatureType->Id.charactersLen);
					}
				}
				grammarID = 6;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1SignedInfoType(stream, &iso1SignatureType->SignedInfo );
				}
				grammarID = 7;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 6:
			/* StartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignedInfo)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1SignedInfoType(stream, &iso1SignatureType->SignedInfo );
				}
				grammarID = 7;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 7:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureValue)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1SignatureValueType(stream, &iso1SignatureType->SignatureValue );
				}
				grammarID = 8;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 8:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyInfo), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Object), END_ELEMENT] */
			if ( iso1SignatureType->KeyInfo_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1KeyInfoType(stream, &iso1SignatureType->KeyInfo );
				}
				grammarID = 9;
			} else 			if (iso1SignatureType_Object_currArrayIndex < iso1SignatureType->Object.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1ObjectType(stream, &iso1SignatureType->Object.array [iso1SignatureType_Object_currArrayIndex++]);
				}
				grammarID = 9;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 9:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Object), END_ELEMENT] */
			if (iso1SignatureType_Object_currArrayIndex < iso1SignatureType->Object.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ObjectType(stream, &iso1SignatureType->Object.array [iso1SignatureType_Object_currArrayIndex++]);
				}
				grammarID = 9;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,PowerDeliveryReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ChargeProgress,"urn:iso:15118:2:2013:MsgBody":SAScheduleTupleID,"urn:iso:15118:2:2013:MsgBody":ChargingProfile{0-1},"urn:iso:15118:2:2013:MsgDataTypes":EVPowerDeliveryParameter{0-1})',  derivedBy='EXTENSION'.  */
static int encode_iso1PowerDeliveryReqType(bitstream_t* stream, struct iso1PowerDeliveryReqType* iso1PowerDeliveryReqType) {
	int grammarID = 10;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 10:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeProgress)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, iso1PowerDeliveryReqType->ChargeProgress);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 11;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 11:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SAScheduleTupleID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(iso1PowerDeliveryReqType->SAScheduleTupleID - 1));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 12;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 12:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingProfile), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVPowerDeliveryParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVPowerDeliveryParameter), END_ELEMENT] */
			if ( iso1PowerDeliveryReqType->ChargingProfile_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_iso1ChargingProfileType(stream, &iso1PowerDeliveryReqType->ChargingProfile );
				}
				grammarID = 13;
			} else 			if ( iso1PowerDeliveryReqType->DC_EVPowerDeliveryParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					errn = encode_iso1DC_EVPowerDeliveryParameterType(stream, &iso1PowerDeliveryReqType->DC_EVPowerDeliveryParameter );
				}
				grammarID = 3;
			} else 			if ( iso1PowerDeliveryReqType->EVPowerDeliveryParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					errn = encode_iso1EVPowerDeliveryParameterType(stream, &iso1PowerDeliveryReqType->EVPowerDeliveryParameter );
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 13:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVPowerDeliveryParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVPowerDeliveryParameter), END_ELEMENT] */
			if ( iso1PowerDeliveryReqType->DC_EVPowerDeliveryParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1DC_EVPowerDeliveryParameterType(stream, &iso1PowerDeliveryReqType->DC_EVPowerDeliveryParameter );
				}
				grammarID = 3;
			} else 			if ( iso1PowerDeliveryReqType->EVPowerDeliveryParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1EVPowerDeliveryParameterType(stream, &iso1PowerDeliveryReqType->EVPowerDeliveryParameter );
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,ParameterType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":boolValue|"urn:iso:15118:2:2013:MsgDataTypes":byteValue|"urn:iso:15118:2:2013:MsgDataTypes":shortValue|"urn:iso:15118:2:2013:MsgDataTypes":intValue|"urn:iso:15118:2:2013:MsgDataTypes":physicalValue|"urn:iso:15118:2:2013:MsgDataTypes":stringValue)',  derivedBy='RESTRICTION'.  */
static int encode_iso1ParameterType(bitstream_t* stream, struct iso1ParameterType* iso1ParameterType) {
	int grammarID = 14;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 14:
			/* FirstStartTag[ATTRIBUTE[STRING]({urn:iso:15118:2:2013:MsgDataTypes}Name)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ParameterType->Name.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1ParameterType->Name.characters, iso1ParameterType->Name.charactersLen);
					}
				}
				grammarID = 15;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 15:
			/* StartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}boolValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}byteValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}shortValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}intValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}physicalValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}stringValue)] */
			if ( iso1ParameterType->boolValue_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1ParameterType->boolValue);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if ( iso1ParameterType->byteValue_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(iso1ParameterType->byteValue + 128));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if ( iso1ParameterType->shortValue_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, iso1ParameterType->shortValue);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if ( iso1ParameterType->intValue_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger32(stream, iso1ParameterType->intValue);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if ( iso1ParameterType->physicalValue_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 4);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1ParameterType->physicalValue );
				}
				grammarID = 3;
			} else 			if ( iso1ParameterType->stringValue_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 5);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ParameterType->stringValue.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1ParameterType->stringValue.characters, iso1ParameterType->stringValue.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,CertificateInstallationReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":OEMProvisioningCert,"urn:iso:15118:2:2013:MsgBody":ListOfRootCertificateIDs)',  derivedBy='EXTENSION'.  */
static int encode_iso1CertificateInstallationReqType(bitstream_t* stream, struct iso1CertificateInstallationReqType* iso1CertificateInstallationReqType) {
	int grammarID = 16;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 16:
			/* FirstStartTag[ATTRIBUTE[STRING]({urn:iso:15118:2:2013:MsgBody}Id)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1CertificateInstallationReqType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1CertificateInstallationReqType->Id.characters, iso1CertificateInstallationReqType->Id.charactersLen);
					}
				}
				grammarID = 17;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 17:
			/* StartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}OEMProvisioningCert)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1CertificateInstallationReqType->OEMProvisioningCert.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1CertificateInstallationReqType->OEMProvisioningCert.bytes, iso1CertificateInstallationReqType->OEMProvisioningCert.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 18;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 18:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ListOfRootCertificateIDs)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1ListOfRootCertificateIDsType(stream, &iso1CertificateInstallationReqType->ListOfRootCertificateIDs );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,SessionSetupResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ResponseCode,"urn:iso:15118:2:2013:MsgBody":EVSEID,"urn:iso:15118:2:2013:MsgBody":EVSETimeStamp{0-1})',  derivedBy='EXTENSION'.  */
static int encode_iso1SessionSetupResType(bitstream_t* stream, struct iso1SessionSetupResType* iso1SessionSetupResType) {
	int grammarID = 19;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 19:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, iso1SessionSetupResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 20;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 20:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SessionSetupResType->EVSEID.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1SessionSetupResType->EVSEID.characters, iso1SessionSetupResType->EVSEID.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 21;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 21:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSETimeStamp), END_ELEMENT] */
			if ( iso1SessionSetupResType->EVSETimeStamp_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger64(stream, iso1SessionSetupResType->EVSETimeStamp);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,EVChargeParameterType',  base type name='anyType',  content type='ELEMENT',  isAbstract='true',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":DepartureTime{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_iso1EVChargeParameterType(bitstream_t* stream, struct iso1EVChargeParameterType* iso1EVChargeParameterType) {
	int grammarID = 22;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 22:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DepartureTime), END_ELEMENT] */
			if ( iso1EVChargeParameterType->DepartureTime_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger32(stream, iso1EVChargeParameterType->DepartureTime);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,DiffieHellmanPublickeyType',  base type name='dHpublickeyType',  content type='SIMPLE',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  derivedBy='EXTENSION'.  */
static int encode_iso1DiffieHellmanPublickeyType(bitstream_t* stream, struct iso1DiffieHellmanPublickeyType* iso1DiffieHellmanPublickeyType) {
	int grammarID = 23;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 23:
			/* FirstStartTag[ATTRIBUTE[STRING]({urn:iso:15118:2:2013:MsgDataTypes}Id)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1DiffieHellmanPublickeyType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1DiffieHellmanPublickeyType->Id.characters, iso1DiffieHellmanPublickeyType->Id.charactersLen);
					}
				}
				grammarID = 24;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 24:
			/* StartTag[CHARACTERS[BINARY_BASE64]] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1DiffieHellmanPublickeyType->CONTENT.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, iso1DiffieHellmanPublickeyType->CONTENT.bytes, iso1DiffieHellmanPublickeyType->CONTENT.bytesLen);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,ServiceDiscoveryResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ResponseCode,"urn:iso:15118:2:2013:MsgBody":PaymentOptionList,"urn:iso:15118:2:2013:MsgBody":ChargeService,"urn:iso:15118:2:2013:MsgBody":ServiceList{0-1})',  derivedBy='EXTENSION'.  */
static int encode_iso1ServiceDiscoveryResType(bitstream_t* stream, struct iso1ServiceDiscoveryResType* iso1ServiceDiscoveryResType) {
	int grammarID = 25;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 25:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, iso1ServiceDiscoveryResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 26;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 26:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentOptionList)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PaymentOptionListType(stream, &iso1ServiceDiscoveryResType->PaymentOptionList );
				}
				grammarID = 27;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 27:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeService)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1ChargeServiceType(stream, &iso1ServiceDiscoveryResType->ChargeService );
				}
				grammarID = 28;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 28:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceList), END_ELEMENT] */
			if ( iso1ServiceDiscoveryResType->ServiceList_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ServiceListType(stream, &iso1ServiceDiscoveryResType->ServiceList );
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,ServiceParameterListType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":ParameterSet{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_iso1ServiceParameterListType(bitstream_t* stream, struct iso1ServiceParameterListType* iso1ServiceParameterListType) {
	int grammarID = 29;
	int done = 0;
	
	unsigned int iso1ServiceParameterListType_ParameterSet_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 29:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ParameterSet)] */
			if (iso1ServiceParameterListType_ParameterSet_currArrayIndex < iso1ServiceParameterListType->ParameterSet.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1ParameterSetType(stream, &iso1ServiceParameterListType->ParameterSet.array [iso1ServiceParameterListType_ParameterSet_currArrayIndex++]);
				}
				grammarID = 30;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 30:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ParameterSet), END_ELEMENT] */
			if (iso1ServiceParameterListType_ParameterSet_currArrayIndex < iso1ServiceParameterListType->ParameterSet.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ParameterSetType(stream, &iso1ServiceParameterListType->ParameterSet.array [iso1ServiceParameterListType_ParameterSet_currArrayIndex++]);
				}
				grammarID = 30;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,CertificateChainType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":Certificate,"urn:iso:15118:2:2013:MsgDataTypes":SubCertificates{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_iso1CertificateChainType(bitstream_t* stream, struct iso1CertificateChainType* iso1CertificateChainType) {
	int grammarID = 31;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 31:
			/* FirstStartTag[ATTRIBUTE[STRING]({urn:iso:15118:2:2013:MsgDataTypes}Id), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Certificate)] */
			if ( iso1CertificateChainType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1CertificateChainType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1CertificateChainType->Id.characters, iso1CertificateChainType->Id.charactersLen);
					}
				}
				grammarID = 32;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1CertificateChainType->Certificate.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1CertificateChainType->Certificate.bytes, iso1CertificateChainType->Certificate.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 33;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 32:
			/* StartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Certificate)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1CertificateChainType->Certificate.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1CertificateChainType->Certificate.bytes, iso1CertificateChainType->Certificate.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 33;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 33:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SubCertificates), END_ELEMENT] */
			if ( iso1CertificateChainType->SubCertificates_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SubCertificatesType(stream, &iso1CertificateChainType->SubCertificates );
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,SASchedulesType',  base type name='anyType',  content type='EMPTY',  isAbstract='true',  hasTypeId='false',  final='0',  block='0',  derivedBy='RESTRICTION'.  */
static int encode_iso1SASchedulesType(bitstream_t* stream, struct iso1SASchedulesType* iso1SASchedulesType) {
	int grammarID = 34;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 34:
			/* FirstStartTag[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,DC_EVSEStatusType',  base type name='EVSEStatusType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='(("urn:iso:15118:2:2013:MsgDataTypes":NotificationMaxDelay,"urn:iso:15118:2:2013:MsgDataTypes":EVSENotification),("urn:iso:15118:2:2013:MsgDataTypes":EVSEIsolationStatus{0-1},"urn:iso:15118:2:2013:MsgDataTypes":EVSEStatusCode))',  derivedBy='EXTENSION'.  */
static int encode_iso1DC_EVSEStatusType(bitstream_t* stream, struct iso1DC_EVSEStatusType* iso1DC_EVSEStatusType) {
	int grammarID = 35;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 35:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}NotificationMaxDelay)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, iso1DC_EVSEStatusType->NotificationMaxDelay);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 36;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 36:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSENotification)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, iso1DC_EVSEStatusType->EVSENotification);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 37;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 37:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEIsolationStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEStatusCode)] */
			if ( iso1DC_EVSEStatusType->EVSEIsolationStatus_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 3, iso1DC_EVSEStatusType->EVSEIsolationStatus);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 38;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 4, iso1DC_EVSEStatusType->EVSEStatusCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 38:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEStatusCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 4, iso1DC_EVSEStatusType->EVSEStatusCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,PreChargeResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ResponseCode,"urn:iso:15118:2:2013:MsgBody":DC_EVSEStatus,"urn:iso:15118:2:2013:MsgBody":EVSEPresentVoltage)',  derivedBy='EXTENSION'.  */
static int encode_iso1PreChargeResType(bitstream_t* stream, struct iso1PreChargeResType* iso1PreChargeResType) {
	int grammarID = 39;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 39:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, iso1PreChargeResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 40;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 40:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DC_EVSEStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1DC_EVSEStatusType(stream, &iso1PreChargeResType->DC_EVSEStatus );
				}
				grammarID = 41;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 41:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEPresentVoltage)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1PreChargeResType->EVSEPresentVoltage );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,ParameterSetType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":ParameterSetID,"urn:iso:15118:2:2013:MsgDataTypes":Parameter{1-16})',  derivedBy='RESTRICTION'.  */
static int encode_iso1ParameterSetType(bitstream_t* stream, struct iso1ParameterSetType* iso1ParameterSetType) {
	int grammarID = 42;
	int done = 0;
	
	unsigned int iso1ParameterSetType_Parameter_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 42:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ParameterSetID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, iso1ParameterSetType->ParameterSetID);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 43;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 43:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter)] */
			if (iso1ParameterSetType_Parameter_currArrayIndex < iso1ParameterSetType->Parameter.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1ParameterType(stream, &iso1ParameterSetType->Parameter.array [iso1ParameterSetType_Parameter_currArrayIndex++]);
				}
				grammarID = 44;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 44:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter), END_ELEMENT] */
			if (iso1ParameterSetType_Parameter_currArrayIndex < iso1ParameterSetType->Parameter.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ParameterType(stream, &iso1ParameterSetType->Parameter.array [iso1ParameterSetType_Parameter_currArrayIndex++]);
				}
				grammarID = 45;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 45:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter), END_ELEMENT] */
			if (iso1ParameterSetType_Parameter_currArrayIndex < iso1ParameterSetType->Parameter.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ParameterType(stream, &iso1ParameterSetType->Parameter.array [iso1ParameterSetType_Parameter_currArrayIndex++]);
				}
				grammarID = 46;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 46:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter), END_ELEMENT] */
			if (iso1ParameterSetType_Parameter_currArrayIndex < iso1ParameterSetType->Parameter.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ParameterType(stream, &iso1ParameterSetType->Parameter.array [iso1ParameterSetType_Parameter_currArrayIndex++]);
				}
				grammarID = 47;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 47:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter), END_ELEMENT] */
			if (iso1ParameterSetType_Parameter_currArrayIndex < iso1ParameterSetType->Parameter.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ParameterType(stream, &iso1ParameterSetType->Parameter.array [iso1ParameterSetType_Parameter_currArrayIndex++]);
				}
				grammarID = 48;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 48:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter), END_ELEMENT] */
			if (iso1ParameterSetType_Parameter_currArrayIndex < iso1ParameterSetType->Parameter.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ParameterType(stream, &iso1ParameterSetType->Parameter.array [iso1ParameterSetType_Parameter_currArrayIndex++]);
				}
				grammarID = 49;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 49:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter), END_ELEMENT] */
			if (iso1ParameterSetType_Parameter_currArrayIndex < iso1ParameterSetType->Parameter.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ParameterType(stream, &iso1ParameterSetType->Parameter.array [iso1ParameterSetType_Parameter_currArrayIndex++]);
				}
				grammarID = 50;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 50:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter), END_ELEMENT] */
			if (iso1ParameterSetType_Parameter_currArrayIndex < iso1ParameterSetType->Parameter.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ParameterType(stream, &iso1ParameterSetType->Parameter.array [iso1ParameterSetType_Parameter_currArrayIndex++]);
				}
				grammarID = 51;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 51:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter), END_ELEMENT] */
			if (iso1ParameterSetType_Parameter_currArrayIndex < iso1ParameterSetType->Parameter.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ParameterType(stream, &iso1ParameterSetType->Parameter.array [iso1ParameterSetType_Parameter_currArrayIndex++]);
				}
				grammarID = 52;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 52:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter), END_ELEMENT] */
			if (iso1ParameterSetType_Parameter_currArrayIndex < iso1ParameterSetType->Parameter.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ParameterType(stream, &iso1ParameterSetType->Parameter.array [iso1ParameterSetType_Parameter_currArrayIndex++]);
				}
				grammarID = 53;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 53:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter), END_ELEMENT] */
			if (iso1ParameterSetType_Parameter_currArrayIndex < iso1ParameterSetType->Parameter.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ParameterType(stream, &iso1ParameterSetType->Parameter.array [iso1ParameterSetType_Parameter_currArrayIndex++]);
				}
				grammarID = 54;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 54:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter), END_ELEMENT] */
			if (iso1ParameterSetType_Parameter_currArrayIndex < iso1ParameterSetType->Parameter.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ParameterType(stream, &iso1ParameterSetType->Parameter.array [iso1ParameterSetType_Parameter_currArrayIndex++]);
				}
				grammarID = 55;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 55:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter), END_ELEMENT] */
			if (iso1ParameterSetType_Parameter_currArrayIndex < iso1ParameterSetType->Parameter.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ParameterType(stream, &iso1ParameterSetType->Parameter.array [iso1ParameterSetType_Parameter_currArrayIndex++]);
				}
				grammarID = 56;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 56:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter), END_ELEMENT] */
			if (iso1ParameterSetType_Parameter_currArrayIndex < iso1ParameterSetType->Parameter.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ParameterType(stream, &iso1ParameterSetType->Parameter.array [iso1ParameterSetType_Parameter_currArrayIndex++]);
				}
				grammarID = 57;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 57:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter), END_ELEMENT] */
			if (iso1ParameterSetType_Parameter_currArrayIndex < iso1ParameterSetType->Parameter.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ParameterType(stream, &iso1ParameterSetType->Parameter.array [iso1ParameterSetType_Parameter_currArrayIndex++]);
				}
				grammarID = 58;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 58:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter), END_ELEMENT] */
			if (iso1ParameterSetType_Parameter_currArrayIndex < iso1ParameterSetType->Parameter.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ParameterType(stream, &iso1ParameterSetType->Parameter.array [iso1ParameterSetType_Parameter_currArrayIndex++]);
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,ServiceDetailReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ServiceID)',  derivedBy='EXTENSION'.  */
static int encode_iso1ServiceDetailReqType(bitstream_t* stream, struct iso1ServiceDetailReqType* iso1ServiceDetailReqType) {
	int grammarID = 59;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 59:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, iso1ServiceDetailReqType->ServiceID);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,RelativeTimeIntervalType',  base type name='IntervalType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":start,"urn:iso:15118:2:2013:MsgDataTypes":duration{0-1})',  derivedBy='EXTENSION'.  */
static int encode_iso1RelativeTimeIntervalType(bitstream_t* stream, struct iso1RelativeTimeIntervalType* iso1RelativeTimeIntervalType) {
	int grammarID = 60;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 60:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}start)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger32(stream, iso1RelativeTimeIntervalType->start);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 61;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 61:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}duration), END_ELEMENT] */
			if ( iso1RelativeTimeIntervalType->duration_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger32(stream, iso1RelativeTimeIntervalType->duration);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,SignedInfoType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":CanonicalizationMethod,"http://www.w3.org/2000/09/xmldsig#":SignatureMethod,"http://www.w3.org/2000/09/xmldsig#":Reference{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_iso1SignedInfoType(bitstream_t* stream, struct iso1SignedInfoType* iso1SignedInfoType) {
	int grammarID = 62;
	int done = 0;
	
	unsigned int iso1SignedInfoType_Reference_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 62:
			/* FirstStartTag[ATTRIBUTE[STRING](Id), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}CanonicalizationMethod)] */
			if ( iso1SignedInfoType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SignedInfoType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1SignedInfoType->Id.characters, iso1SignedInfoType->Id.charactersLen);
					}
				}
				grammarID = 63;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1CanonicalizationMethodType(stream, &iso1SignedInfoType->CanonicalizationMethod );
				}
				grammarID = 64;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 63:
			/* StartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}CanonicalizationMethod)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1CanonicalizationMethodType(stream, &iso1SignedInfoType->CanonicalizationMethod );
				}
				grammarID = 64;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 64:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureMethod)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1SignatureMethodType(stream, &iso1SignedInfoType->SignatureMethod );
				}
				grammarID = 65;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 65:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference)] */
			if (iso1SignedInfoType_Reference_currArrayIndex < iso1SignedInfoType->Reference.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1ReferenceType(stream, &iso1SignedInfoType->Reference.array [iso1SignedInfoType_Reference_currArrayIndex++]);
				}
				grammarID = 66;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 66:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference), END_ELEMENT] */
			if (iso1SignedInfoType_Reference_currArrayIndex < iso1SignedInfoType->Reference.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ReferenceType(stream, &iso1SignedInfoType->Reference.array [iso1SignedInfoType_Reference_currArrayIndex++]);
				}
				grammarID = 66;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,EMAIDType',  base type name='eMAIDType',  content type='SIMPLE',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  derivedBy='EXTENSION'.  */
static int encode_iso1EMAIDType(bitstream_t* stream, struct iso1EMAIDType* iso1EMAIDType) {
	int grammarID = 67;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 67:
			/* FirstStartTag[ATTRIBUTE[STRING]({urn:iso:15118:2:2013:MsgDataTypes}Id)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1EMAIDType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1EMAIDType->Id.characters, iso1EMAIDType->Id.charactersLen);
					}
				}
				grammarID = 68;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 68:
			/* StartTag[CHARACTERS[STRING]] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1EMAIDType->CONTENT.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1EMAIDType->CONTENT.characters, iso1EMAIDType->CONTENT.charactersLen);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,EVStatusType',  base type name='anyType',  content type='EMPTY',  isAbstract='true',  hasTypeId='false',  final='0',  block='0',  derivedBy='RESTRICTION'.  */
static int encode_iso1EVStatusType(bitstream_t* stream, struct iso1EVStatusType* iso1EVStatusType) {
	int grammarID = 34;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 34:
			/* FirstStartTag[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,ServiceListType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":Service{1-8})',  derivedBy='RESTRICTION'.  */
static int encode_iso1ServiceListType(bitstream_t* stream, struct iso1ServiceListType* iso1ServiceListType) {
	int grammarID = 69;
	int done = 0;
	
	unsigned int iso1ServiceListType_Service_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 69:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Service)] */
			if (iso1ServiceListType_Service_currArrayIndex < iso1ServiceListType->Service.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1ServiceType(stream, &iso1ServiceListType->Service.array [iso1ServiceListType_Service_currArrayIndex++]);
				}
				grammarID = 70;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 70:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Service), END_ELEMENT] */
			if (iso1ServiceListType_Service_currArrayIndex < iso1ServiceListType->Service.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ServiceType(stream, &iso1ServiceListType->Service.array [iso1ServiceListType_Service_currArrayIndex++]);
				}
				grammarID = 71;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 71:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Service), END_ELEMENT] */
			if (iso1ServiceListType_Service_currArrayIndex < iso1ServiceListType->Service.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ServiceType(stream, &iso1ServiceListType->Service.array [iso1ServiceListType_Service_currArrayIndex++]);
				}
				grammarID = 72;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 72:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Service), END_ELEMENT] */
			if (iso1ServiceListType_Service_currArrayIndex < iso1ServiceListType->Service.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ServiceType(stream, &iso1ServiceListType->Service.array [iso1ServiceListType_Service_currArrayIndex++]);
				}
				grammarID = 73;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 73:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Service), END_ELEMENT] */
			if (iso1ServiceListType_Service_currArrayIndex < iso1ServiceListType->Service.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ServiceType(stream, &iso1ServiceListType->Service.array [iso1ServiceListType_Service_currArrayIndex++]);
				}
				grammarID = 74;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 74:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Service), END_ELEMENT] */
			if (iso1ServiceListType_Service_currArrayIndex < iso1ServiceListType->Service.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ServiceType(stream, &iso1ServiceListType->Service.array [iso1ServiceListType_Service_currArrayIndex++]);
				}
				grammarID = 75;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 75:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Service), END_ELEMENT] */
			if (iso1ServiceListType_Service_currArrayIndex < iso1ServiceListType->Service.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ServiceType(stream, &iso1ServiceListType->Service.array [iso1ServiceListType_Service_currArrayIndex++]);
				}
				grammarID = 76;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 76:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Service), END_ELEMENT] */
			if (iso1ServiceListType_Service_currArrayIndex < iso1ServiceListType->Service.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ServiceType(stream, &iso1ServiceListType->Service.array [iso1ServiceListType_Service_currArrayIndex++]);
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,EVSEChargeParameterType',  base type name='anyType',  content type='EMPTY',  isAbstract='true',  hasTypeId='false',  final='0',  block='0',  derivedBy='RESTRICTION'.  */
static int encode_iso1EVSEChargeParameterType(bitstream_t* stream, struct iso1EVSEChargeParameterType* iso1EVSEChargeParameterType) {
	int grammarID = 34;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 34:
			/* FirstStartTag[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,EVPowerDeliveryParameterType',  base type name='anyType',  content type='EMPTY',  isAbstract='true',  hasTypeId='false',  final='0',  block='0',  derivedBy='RESTRICTION'.  */
static int encode_iso1EVPowerDeliveryParameterType(bitstream_t* stream, struct iso1EVPowerDeliveryParameterType* iso1EVPowerDeliveryParameterType) {
	int grammarID = 34;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 34:
			/* FirstStartTag[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,ProfileEntryType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":ChargingProfileEntryStart,"urn:iso:15118:2:2013:MsgDataTypes":ChargingProfileEntryMaxPower,"urn:iso:15118:2:2013:MsgDataTypes":ChargingProfileEntryMaxNumberOfPhasesInUse{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_iso1ProfileEntryType(bitstream_t* stream, struct iso1ProfileEntryType* iso1ProfileEntryType) {
	int grammarID = 77;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 77:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingProfileEntryStart)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger32(stream, iso1ProfileEntryType->ChargingProfileEntryStart);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 78;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 78:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingProfileEntryMaxPower)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1ProfileEntryType->ChargingProfileEntryMaxPower );
				}
				grammarID = 79;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 79:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingProfileEntryMaxNumberOfPhasesInUse), END_ELEMENT] */
			if ( iso1ProfileEntryType->ChargingProfileEntryMaxNumberOfPhasesInUse_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, (uint32_t)(iso1ProfileEntryType->ChargingProfileEntryMaxNumberOfPhasesInUse - 1));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,AuthorizationReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":GenChallenge{0-1})',  derivedBy='EXTENSION'.  */
static int encode_iso1AuthorizationReqType(bitstream_t* stream, struct iso1AuthorizationReqType* iso1AuthorizationReqType) {
	int grammarID = 80;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 80:
			/* FirstStartTag[ATTRIBUTE[STRING]({urn:iso:15118:2:2013:MsgBody}Id), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}GenChallenge), END_ELEMENT] */
			if ( iso1AuthorizationReqType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1AuthorizationReqType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1AuthorizationReqType->Id.characters, iso1AuthorizationReqType->Id.charactersLen);
					}
				}
				grammarID = 81;
			} else 			if ( iso1AuthorizationReqType->GenChallenge_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1AuthorizationReqType->GenChallenge.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1AuthorizationReqType->GenChallenge.bytes, iso1AuthorizationReqType->GenChallenge.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 81:
			/* StartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}GenChallenge), END_ELEMENT] */
			if ( iso1AuthorizationReqType->GenChallenge_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1AuthorizationReqType->GenChallenge.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1AuthorizationReqType->GenChallenge.bytes, iso1AuthorizationReqType->GenChallenge.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,MeterInfoType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":MeterID,"urn:iso:15118:2:2013:MsgDataTypes":MeterReading{0-1},"urn:iso:15118:2:2013:MsgDataTypes":SigMeterReading{0-1},"urn:iso:15118:2:2013:MsgDataTypes":MeterStatus{0-1},"urn:iso:15118:2:2013:MsgDataTypes":TMeter{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_iso1MeterInfoType(bitstream_t* stream, struct iso1MeterInfoType* iso1MeterInfoType) {
	int grammarID = 82;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 82:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}MeterID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1MeterInfoType->MeterID.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1MeterInfoType->MeterID.characters, iso1MeterInfoType->MeterID.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 83;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 83:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SigMeterReading), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}TMeter), END_ELEMENT] */
			if ( iso1MeterInfoType->MeterReading_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger64(stream, iso1MeterInfoType->MeterReading);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 84;
			} else 			if ( iso1MeterInfoType->SigMeterReading_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1MeterInfoType->SigMeterReading.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1MeterInfoType->SigMeterReading.bytes, iso1MeterInfoType->SigMeterReading.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 85;
			} else 			if ( iso1MeterInfoType->MeterStatus_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, iso1MeterInfoType->MeterStatus);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 86;
			} else 			if ( iso1MeterInfoType->TMeter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger64(stream, iso1MeterInfoType->TMeter);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 3, 4);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 84:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SigMeterReading), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}TMeter), END_ELEMENT] */
			if ( iso1MeterInfoType->SigMeterReading_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1MeterInfoType->SigMeterReading.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1MeterInfoType->SigMeterReading.bytes, iso1MeterInfoType->SigMeterReading.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 85;
			} else 			if ( iso1MeterInfoType->MeterStatus_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, iso1MeterInfoType->MeterStatus);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 86;
			} else 			if ( iso1MeterInfoType->TMeter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger64(stream, iso1MeterInfoType->TMeter);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 85:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}TMeter), END_ELEMENT] */
			if ( iso1MeterInfoType->MeterStatus_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, iso1MeterInfoType->MeterStatus);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 86;
			} else 			if ( iso1MeterInfoType->TMeter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger64(stream, iso1MeterInfoType->TMeter);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 86:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}TMeter), END_ELEMENT] */
			if ( iso1MeterInfoType->TMeter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger64(stream, iso1MeterInfoType->TMeter);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,ManifestType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":Reference{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_iso1ManifestType(bitstream_t* stream, struct iso1ManifestType* iso1ManifestType) {
	int grammarID = 87;
	int done = 0;
	
	unsigned int iso1ManifestType_Reference_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 87:
			/* FirstStartTag[ATTRIBUTE[STRING](Id), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference)] */
			if ( iso1ManifestType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ManifestType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1ManifestType->Id.characters, iso1ManifestType->Id.charactersLen);
					}
				}
				grammarID = 88;
			} else 			if (iso1ManifestType_Reference_currArrayIndex < iso1ManifestType->Reference.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1ReferenceType(stream, &iso1ManifestType->Reference.array [iso1ManifestType_Reference_currArrayIndex++]);
				}
				grammarID = 66;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 88:
			/* StartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference)] */
			if (iso1ManifestType_Reference_currArrayIndex < iso1ManifestType->Reference.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1ReferenceType(stream, &iso1ManifestType->Reference.array [iso1ManifestType_Reference_currArrayIndex++]);
				}
				grammarID = 66;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 66:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference), END_ELEMENT] */
			if (iso1ManifestType_Reference_currArrayIndex < iso1ManifestType->Reference.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ReferenceType(stream, &iso1ManifestType->Reference.array [iso1ManifestType_Reference_currArrayIndex++]);
				}
				grammarID = 66;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,ChargeParameterDiscoveryResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ResponseCode,"urn:iso:15118:2:2013:MsgBody":EVSEProcessing,"urn:iso:15118:2:2013:MsgDataTypes":SASchedules{0-1},"urn:iso:15118:2:2013:MsgDataTypes":EVSEChargeParameter)',  derivedBy='EXTENSION'.  */
static int encode_iso1ChargeParameterDiscoveryResType(bitstream_t* stream, struct iso1ChargeParameterDiscoveryResType* iso1ChargeParameterDiscoveryResType) {
	int grammarID = 89;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 89:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, iso1ChargeParameterDiscoveryResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 90;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 90:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEProcessing)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, iso1ChargeParameterDiscoveryResType->EVSEProcessing);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 91;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 91:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleList), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SASchedules), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEChargeParameter)] */
			if ( iso1ChargeParameterDiscoveryResType->SAScheduleList_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_iso1SAScheduleListType(stream, &iso1ChargeParameterDiscoveryResType->SAScheduleList );
				}
				grammarID = 92;
			} else 			if ( iso1ChargeParameterDiscoveryResType->SASchedules_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					errn = encode_iso1SASchedulesType(stream, &iso1ChargeParameterDiscoveryResType->SASchedules );
				}
				grammarID = 92;
			} else 			if ( iso1ChargeParameterDiscoveryResType->AC_EVSEChargeParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					errn = encode_iso1AC_EVSEChargeParameterType(stream, &iso1ChargeParameterDiscoveryResType->AC_EVSEChargeParameter );
				}
				grammarID = 3;
			} else 			if ( iso1ChargeParameterDiscoveryResType->DC_EVSEChargeParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					errn = encode_iso1DC_EVSEChargeParameterType(stream, &iso1ChargeParameterDiscoveryResType->DC_EVSEChargeParameter );
				}
				grammarID = 3;
			} else 			if ( iso1ChargeParameterDiscoveryResType->EVSEChargeParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 4);
				if(errn == 0) {
					errn = encode_iso1EVSEChargeParameterType(stream, &iso1ChargeParameterDiscoveryResType->EVSEChargeParameter );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 92:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEChargeParameter)] */
			if ( iso1ChargeParameterDiscoveryResType->AC_EVSEChargeParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1AC_EVSEChargeParameterType(stream, &iso1ChargeParameterDiscoveryResType->AC_EVSEChargeParameter );
				}
				grammarID = 3;
			} else 			if ( iso1ChargeParameterDiscoveryResType->DC_EVSEChargeParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1DC_EVSEChargeParameterType(stream, &iso1ChargeParameterDiscoveryResType->DC_EVSEChargeParameter );
				}
				grammarID = 3;
			} else 			if ( iso1ChargeParameterDiscoveryResType->EVSEChargeParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					errn = encode_iso1EVSEChargeParameterType(stream, &iso1ChargeParameterDiscoveryResType->EVSEChargeParameter );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,PowerDeliveryResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ResponseCode,"urn:iso:15118:2:2013:MsgDataTypes":EVSEStatus)',  derivedBy='EXTENSION'.  */
static int encode_iso1PowerDeliveryResType(bitstream_t* stream, struct iso1PowerDeliveryResType* iso1PowerDeliveryResType) {
	int grammarID = 93;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 93:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, iso1PowerDeliveryResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 94;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 94:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEStatus)] */
			if ( iso1PowerDeliveryResType->AC_EVSEStatus_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1AC_EVSEStatusType(stream, &iso1PowerDeliveryResType->AC_EVSEStatus );
				}
				grammarID = 3;
			} else 			if ( iso1PowerDeliveryResType->DC_EVSEStatus_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1DC_EVSEStatusType(stream, &iso1PowerDeliveryResType->DC_EVSEStatus );
				}
				grammarID = 3;
			} else 			if ( iso1PowerDeliveryResType->EVSEStatus_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					errn = encode_iso1EVSEStatusType(stream, &iso1PowerDeliveryResType->EVSEStatus );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,DC_EVChargeParameterType',  base type name='EVChargeParameterType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='(("urn:iso:15118:2:2013:MsgDataTypes":DepartureTime{0-1}),("urn:iso:15118:2:2013:MsgDataTypes":DC_EVStatus,"urn:iso:15118:2:2013:MsgDataTypes":EVMaximumCurrentLimit,"urn:iso:15118:2:2013:MsgDataTypes":EVMaximumPowerLimit{0-1},"urn:iso:15118:2:2013:MsgDataTypes":EVMaximumVoltageLimit,"urn:iso:15118:2:2013:MsgDataTypes":EVEnergyCapacity{0-1},"urn:iso:15118:2:2013:MsgDataTypes":EVEnergyRequest{0-1},"urn:iso:15118:2:2013:MsgDataTypes":FullSOC{0-1},"urn:iso:15118:2:2013:MsgDataTypes":BulkSOC{0-1}))',  derivedBy='EXTENSION'.  */
static int encode_iso1DC_EVChargeParameterType(bitstream_t* stream, struct iso1DC_EVChargeParameterType* iso1DC_EVChargeParameterType) {
	int grammarID = 95;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 95:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DepartureTime), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVStatus)] */
			if ( iso1DC_EVChargeParameterType->DepartureTime_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger32(stream, iso1DC_EVChargeParameterType->DepartureTime);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 96;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1DC_EVStatusType(stream, &iso1DC_EVChargeParameterType->DC_EVStatus );
				}
				grammarID = 97;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 96:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1DC_EVStatusType(stream, &iso1DC_EVChargeParameterType->DC_EVStatus );
				}
				grammarID = 97;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 97:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaximumCurrentLimit)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1DC_EVChargeParameterType->EVMaximumCurrentLimit );
				}
				grammarID = 98;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 98:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaximumVoltageLimit)] */
			if ( iso1DC_EVChargeParameterType->EVMaximumPowerLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1DC_EVChargeParameterType->EVMaximumPowerLimit );
				}
				grammarID = 99;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1DC_EVChargeParameterType->EVMaximumVoltageLimit );
				}
				grammarID = 100;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 99:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaximumVoltageLimit)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1DC_EVChargeParameterType->EVMaximumVoltageLimit );
				}
				grammarID = 100;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 100:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVEnergyCapacity), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVEnergyRequest), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FullSOC), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}BulkSOC), END_ELEMENT] */
			if ( iso1DC_EVChargeParameterType->EVEnergyCapacity_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1DC_EVChargeParameterType->EVEnergyCapacity );
				}
				grammarID = 101;
			} else 			if ( iso1DC_EVChargeParameterType->EVEnergyRequest_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1DC_EVChargeParameterType->EVEnergyRequest );
				}
				grammarID = 102;
			} else 			if ( iso1DC_EVChargeParameterType->FullSOC_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(iso1DC_EVChargeParameterType->FullSOC - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 103;
			} else 			if ( iso1DC_EVChargeParameterType->BulkSOC_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(iso1DC_EVChargeParameterType->BulkSOC - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 3, 4);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 101:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVEnergyRequest), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FullSOC), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}BulkSOC), END_ELEMENT] */
			if ( iso1DC_EVChargeParameterType->EVEnergyRequest_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1DC_EVChargeParameterType->EVEnergyRequest );
				}
				grammarID = 102;
			} else 			if ( iso1DC_EVChargeParameterType->FullSOC_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(iso1DC_EVChargeParameterType->FullSOC - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 103;
			} else 			if ( iso1DC_EVChargeParameterType->BulkSOC_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(iso1DC_EVChargeParameterType->BulkSOC - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 102:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FullSOC), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}BulkSOC), END_ELEMENT] */
			if ( iso1DC_EVChargeParameterType->FullSOC_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(iso1DC_EVChargeParameterType->FullSOC - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 103;
			} else 			if ( iso1DC_EVChargeParameterType->BulkSOC_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(iso1DC_EVChargeParameterType->BulkSOC - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 103:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}BulkSOC), END_ELEMENT] */
			if ( iso1DC_EVChargeParameterType->BulkSOC_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(iso1DC_EVChargeParameterType->BulkSOC - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,ConsumptionCostType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":startValue,"urn:iso:15118:2:2013:MsgDataTypes":Cost{1-3})',  derivedBy='RESTRICTION'.  */
static int encode_iso1ConsumptionCostType(bitstream_t* stream, struct iso1ConsumptionCostType* iso1ConsumptionCostType) {
	int grammarID = 104;
	int done = 0;
	
	unsigned int iso1ConsumptionCostType_Cost_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 104:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}startValue)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1ConsumptionCostType->startValue );
				}
				grammarID = 105;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 105:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Cost)] */
			if (iso1ConsumptionCostType_Cost_currArrayIndex < iso1ConsumptionCostType->Cost.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1CostType(stream, &iso1ConsumptionCostType->Cost.array [iso1ConsumptionCostType_Cost_currArrayIndex++]);
				}
				grammarID = 106;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 106:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Cost), END_ELEMENT] */
			if (iso1ConsumptionCostType_Cost_currArrayIndex < iso1ConsumptionCostType->Cost.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1CostType(stream, &iso1ConsumptionCostType->Cost.array [iso1ConsumptionCostType_Cost_currArrayIndex++]);
				}
				grammarID = 107;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 107:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Cost), END_ELEMENT] */
			if (iso1ConsumptionCostType_Cost_currArrayIndex < iso1ConsumptionCostType->Cost.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1CostType(stream, &iso1ConsumptionCostType->Cost.array [iso1ConsumptionCostType_Cost_currArrayIndex++]);
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,PMaxScheduleType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":PMaxScheduleEntry{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_iso1PMaxScheduleType(bitstream_t* stream, struct iso1PMaxScheduleType* iso1PMaxScheduleType) {
	int grammarID = 108;
	int done = 0;
	
	unsigned int iso1PMaxScheduleType_PMaxScheduleEntry_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 108:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMaxScheduleEntry)] */
			if (iso1PMaxScheduleType_PMaxScheduleEntry_currArrayIndex < iso1PMaxScheduleType->PMaxScheduleEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PMaxScheduleEntryType(stream, &iso1PMaxScheduleType->PMaxScheduleEntry.array [iso1PMaxScheduleType_PMaxScheduleEntry_currArrayIndex++]);
				}
				grammarID = 109;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 109:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMaxScheduleEntry), END_ELEMENT] */
			if (iso1PMaxScheduleType_PMaxScheduleEntry_currArrayIndex < iso1PMaxScheduleType->PMaxScheduleEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1PMaxScheduleEntryType(stream, &iso1PMaxScheduleType->PMaxScheduleEntry.array [iso1PMaxScheduleType_PMaxScheduleEntry_currArrayIndex++]);
				}
				grammarID = 109;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,PaymentOptionListType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":PaymentOption{1-2})',  derivedBy='RESTRICTION'.  */
static int encode_iso1PaymentOptionListType(bitstream_t* stream, struct iso1PaymentOptionListType* iso1PaymentOptionListType) {
	int grammarID = 110;
	int done = 0;
	
	unsigned int iso1PaymentOptionListType_PaymentOption_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 110:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PaymentOption)] */
			if (iso1PaymentOptionListType_PaymentOption_currArrayIndex < iso1PaymentOptionListType->PaymentOption.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 1, iso1PaymentOptionListType->PaymentOption.array[iso1PaymentOptionListType_PaymentOption_currArrayIndex++]);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 111;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 111:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PaymentOption), END_ELEMENT] */
			if (iso1PaymentOptionListType_PaymentOption_currArrayIndex < iso1PaymentOptionListType->PaymentOption.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 1, iso1PaymentOptionListType->PaymentOption.array[iso1PaymentOptionListType_PaymentOption_currArrayIndex++]);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,ObjectType',  base type name='anyType',  content type='MIXED',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='((WC[##any])){0-UNBOUNDED}',  derivedBy='RESTRICTION'.  */
static int encode_iso1ObjectType(bitstream_t* stream, struct iso1ObjectType* iso1ObjectType) {
	int grammarID = 112;
	int done = 0;
	int wcDone = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 112:
			/* FirstStartTag[ATTRIBUTE[STRING](Encoding), ATTRIBUTE[STRING](Id), ATTRIBUTE[STRING](MimeType), START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if ( iso1ObjectType->Encoding_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ObjectType->Encoding.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1ObjectType->Encoding.characters, iso1ObjectType->Encoding.charactersLen);
					}
				}
				grammarID = 113;
			} else 			if ( iso1ObjectType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ObjectType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1ObjectType->Id.characters, iso1ObjectType->Id.charactersLen);
					}
				}
				grammarID = 114;
			} else 			if ( iso1ObjectType->MimeType_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ObjectType->MimeType.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1ObjectType->MimeType.characters, iso1ObjectType->MimeType.charactersLen);
					}
				}
				grammarID = 115;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 116;
			} else 			if ( iso1ObjectType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 4);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else 			if ( iso1ObjectType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 5);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ObjectType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1ObjectType->ANY.characters, iso1ObjectType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 116;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 113:
			/* StartTag[ATTRIBUTE[STRING](Id), ATTRIBUTE[STRING](MimeType), START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if ( iso1ObjectType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ObjectType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1ObjectType->Id.characters, iso1ObjectType->Id.charactersLen);
					}
				}
				grammarID = 114;
			} else 			if ( iso1ObjectType->MimeType_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ObjectType->MimeType.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1ObjectType->MimeType.characters, iso1ObjectType->MimeType.charactersLen);
					}
				}
				grammarID = 115;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 116;
			} else 			if ( iso1ObjectType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else 			if ( iso1ObjectType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 4);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ObjectType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1ObjectType->ANY.characters, iso1ObjectType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 116;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 114:
			/* StartTag[ATTRIBUTE[STRING](MimeType), START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if ( iso1ObjectType->MimeType_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ObjectType->MimeType.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1ObjectType->MimeType.characters, iso1ObjectType->MimeType.charactersLen);
					}
				}
				grammarID = 115;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 116;
			} else 			if ( iso1ObjectType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else 			if ( iso1ObjectType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ObjectType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1ObjectType->ANY.characters, iso1ObjectType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 116;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 115:
			/* StartTag[START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 116;
			} else 			if ( iso1ObjectType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else 			if ( iso1ObjectType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ObjectType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1ObjectType->ANY.characters, iso1ObjectType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 116;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 116:
			/* Element[START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 116;
			} else 			if ( iso1ObjectType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else 			if ( iso1ObjectType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ObjectType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1ObjectType->ANY.characters, iso1ObjectType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 116;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,PhysicalValueType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":Multiplier,"urn:iso:15118:2:2013:MsgDataTypes":Unit,"urn:iso:15118:2:2013:MsgDataTypes":Value)',  derivedBy='RESTRICTION'.  */
static int encode_iso1PhysicalValueType(bitstream_t* stream, struct iso1PhysicalValueType* iso1PhysicalValueType) {
	int grammarID = 117;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 117:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Multiplier)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 3, (uint32_t)(iso1PhysicalValueType->Multiplier + 3));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 118;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 118:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Unit)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 3, iso1PhysicalValueType->Unit);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 119;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 119:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Value)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, iso1PhysicalValueType->Value);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,RSAKeyValueType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":Modulus,"http://www.w3.org/2000/09/xmldsig#":Exponent)',  derivedBy='RESTRICTION'.  */
static int encode_iso1RSAKeyValueType(bitstream_t* stream, struct iso1RSAKeyValueType* iso1RSAKeyValueType) {
	int grammarID = 120;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 120:
			/* FirstStartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Modulus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1RSAKeyValueType->Modulus.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1RSAKeyValueType->Modulus.bytes, iso1RSAKeyValueType->Modulus.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 121;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 121:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Exponent)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1RSAKeyValueType->Exponent.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1RSAKeyValueType->Exponent.bytes, iso1RSAKeyValueType->Exponent.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,SessionStopResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ResponseCode)',  derivedBy='EXTENSION'.  */
static int encode_iso1SessionStopResType(bitstream_t* stream, struct iso1SessionStopResType* iso1SessionStopResType) {
	int grammarID = 122;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 122:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, iso1SessionStopResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,CertificateUpdateReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ContractSignatureCertChain,"urn:iso:15118:2:2013:MsgBody":eMAID,"urn:iso:15118:2:2013:MsgBody":ListOfRootCertificateIDs)',  derivedBy='EXTENSION'.  */
static int encode_iso1CertificateUpdateReqType(bitstream_t* stream, struct iso1CertificateUpdateReqType* iso1CertificateUpdateReqType) {
	int grammarID = 123;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 123:
			/* FirstStartTag[ATTRIBUTE[STRING]({urn:iso:15118:2:2013:MsgBody}Id)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1CertificateUpdateReqType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1CertificateUpdateReqType->Id.characters, iso1CertificateUpdateReqType->Id.charactersLen);
					}
				}
				grammarID = 124;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 124:
			/* StartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ContractSignatureCertChain)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1CertificateChainType(stream, &iso1CertificateUpdateReqType->ContractSignatureCertChain );
				}
				grammarID = 125;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 125:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}eMAID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1CertificateUpdateReqType->eMAID.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1CertificateUpdateReqType->eMAID.characters, iso1CertificateUpdateReqType->eMAID.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 18;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 18:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ListOfRootCertificateIDs)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1ListOfRootCertificateIDsType(stream, &iso1CertificateUpdateReqType->ListOfRootCertificateIDs );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,SignatureValueType',  base type name='base64Binary',  content type='SIMPLE',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  derivedBy='EXTENSION'.  */
static int encode_iso1SignatureValueType(bitstream_t* stream, struct iso1SignatureValueType* iso1SignatureValueType) {
	int grammarID = 126;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 126:
			/* FirstStartTag[ATTRIBUTE[STRING](Id), CHARACTERS[BINARY_BASE64]] */
			if ( iso1SignatureValueType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SignatureValueType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1SignatureValueType->Id.characters, iso1SignatureValueType->Id.charactersLen);
					}
				}
				grammarID = 24;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SignatureValueType->CONTENT.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, iso1SignatureValueType->CONTENT.bytes, iso1SignatureValueType->CONTENT.bytesLen);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 24:
			/* StartTag[CHARACTERS[BINARY_BASE64]] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SignatureValueType->CONTENT.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, iso1SignatureValueType->CONTENT.bytes, iso1SignatureValueType->CONTENT.bytesLen);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,PaymentDetailsReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":eMAID,"urn:iso:15118:2:2013:MsgBody":ContractSignatureCertChain)',  derivedBy='EXTENSION'.  */
static int encode_iso1PaymentDetailsReqType(bitstream_t* stream, struct iso1PaymentDetailsReqType* iso1PaymentDetailsReqType) {
	int grammarID = 127;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 127:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}eMAID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1PaymentDetailsReqType->eMAID.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1PaymentDetailsReqType->eMAID.characters, iso1PaymentDetailsReqType->eMAID.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 128;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 128:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ContractSignatureCertChain)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1CertificateChainType(stream, &iso1PaymentDetailsReqType->ContractSignatureCertChain );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,AuthorizationResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ResponseCode,"urn:iso:15118:2:2013:MsgBody":EVSEProcessing)',  derivedBy='EXTENSION'.  */
static int encode_iso1AuthorizationResType(bitstream_t* stream, struct iso1AuthorizationResType* iso1AuthorizationResType) {
	int grammarID = 129;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 129:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, iso1AuthorizationResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 130;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 130:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEProcessing)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, iso1AuthorizationResType->EVSEProcessing);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,DC_EVSEChargeParameterType',  base type name='EVSEChargeParameterType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":DC_EVSEStatus,"urn:iso:15118:2:2013:MsgDataTypes":EVSEMaximumCurrentLimit,"urn:iso:15118:2:2013:MsgDataTypes":EVSEMaximumPowerLimit,"urn:iso:15118:2:2013:MsgDataTypes":EVSEMaximumVoltageLimit,"urn:iso:15118:2:2013:MsgDataTypes":EVSEMinimumCurrentLimit,"urn:iso:15118:2:2013:MsgDataTypes":EVSEMinimumVoltageLimit,"urn:iso:15118:2:2013:MsgDataTypes":EVSECurrentRegulationTolerance{0-1},"urn:iso:15118:2:2013:MsgDataTypes":EVSEPeakCurrentRipple,"urn:iso:15118:2:2013:MsgDataTypes":EVSEEnergyToBeDelivered{0-1})',  derivedBy='EXTENSION'.  */
static int encode_iso1DC_EVSEChargeParameterType(bitstream_t* stream, struct iso1DC_EVSEChargeParameterType* iso1DC_EVSEChargeParameterType) {
	int grammarID = 131;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 131:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1DC_EVSEStatusType(stream, &iso1DC_EVSEChargeParameterType->DC_EVSEStatus );
				}
				grammarID = 132;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 132:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaximumCurrentLimit)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1DC_EVSEChargeParameterType->EVSEMaximumCurrentLimit );
				}
				grammarID = 133;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 133:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaximumPowerLimit)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1DC_EVSEChargeParameterType->EVSEMaximumPowerLimit );
				}
				grammarID = 134;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 134:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaximumVoltageLimit)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1DC_EVSEChargeParameterType->EVSEMaximumVoltageLimit );
				}
				grammarID = 135;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 135:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMinimumCurrentLimit)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1DC_EVSEChargeParameterType->EVSEMinimumCurrentLimit );
				}
				grammarID = 136;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 136:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMinimumVoltageLimit)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1DC_EVSEChargeParameterType->EVSEMinimumVoltageLimit );
				}
				grammarID = 137;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 137:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSECurrentRegulationTolerance), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEPeakCurrentRipple)] */
			if ( iso1DC_EVSEChargeParameterType->EVSECurrentRegulationTolerance_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1DC_EVSEChargeParameterType->EVSECurrentRegulationTolerance );
				}
				grammarID = 138;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1DC_EVSEChargeParameterType->EVSEPeakCurrentRipple );
				}
				grammarID = 139;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 138:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEPeakCurrentRipple)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1DC_EVSEChargeParameterType->EVSEPeakCurrentRipple );
				}
				grammarID = 139;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 139:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEEnergyToBeDelivered), END_ELEMENT] */
			if ( iso1DC_EVSEChargeParameterType->EVSEEnergyToBeDelivered_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1DC_EVSEChargeParameterType->EVSEEnergyToBeDelivered );
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,SubCertificatesType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":Certificate{1-4})',  derivedBy='RESTRICTION'.  */
static int encode_iso1SubCertificatesType(bitstream_t* stream, struct iso1SubCertificatesType* iso1SubCertificatesType) {
	int grammarID = 140;
	int done = 0;
	
	unsigned int iso1SubCertificatesType_Certificate_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 140:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Certificate)] */
			if (iso1SubCertificatesType_Certificate_currArrayIndex < iso1SubCertificatesType->Certificate.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SubCertificatesType->Certificate.array[iso1SubCertificatesType_Certificate_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1SubCertificatesType->Certificate.array[iso1SubCertificatesType_Certificate_currArrayIndex].bytes, iso1SubCertificatesType->Certificate.array[iso1SubCertificatesType_Certificate_currArrayIndex].bytesLen);
							iso1SubCertificatesType_Certificate_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 141;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 141:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Certificate), END_ELEMENT] */
			if (iso1SubCertificatesType_Certificate_currArrayIndex < iso1SubCertificatesType->Certificate.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SubCertificatesType->Certificate.array[iso1SubCertificatesType_Certificate_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1SubCertificatesType->Certificate.array[iso1SubCertificatesType_Certificate_currArrayIndex].bytes, iso1SubCertificatesType->Certificate.array[iso1SubCertificatesType_Certificate_currArrayIndex].bytesLen);
							iso1SubCertificatesType_Certificate_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 142;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 142:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Certificate), END_ELEMENT] */
			if (iso1SubCertificatesType_Certificate_currArrayIndex < iso1SubCertificatesType->Certificate.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SubCertificatesType->Certificate.array[iso1SubCertificatesType_Certificate_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1SubCertificatesType->Certificate.array[iso1SubCertificatesType_Certificate_currArrayIndex].bytes, iso1SubCertificatesType->Certificate.array[iso1SubCertificatesType_Certificate_currArrayIndex].bytesLen);
							iso1SubCertificatesType_Certificate_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 143;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 143:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Certificate), END_ELEMENT] */
			if (iso1SubCertificatesType_Certificate_currArrayIndex < iso1SubCertificatesType->Certificate.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SubCertificatesType->Certificate.array[iso1SubCertificatesType_Certificate_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1SubCertificatesType->Certificate.array[iso1SubCertificatesType_Certificate_currArrayIndex].bytes, iso1SubCertificatesType->Certificate.array[iso1SubCertificatesType_Certificate_currArrayIndex].bytesLen);
							iso1SubCertificatesType_Certificate_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,ChargingStatusResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ResponseCode,"urn:iso:15118:2:2013:MsgBody":EVSEID,"urn:iso:15118:2:2013:MsgBody":SAScheduleTupleID,"urn:iso:15118:2:2013:MsgBody":EVSEMaxCurrent{0-1},"urn:iso:15118:2:2013:MsgBody":MeterInfo{0-1},"urn:iso:15118:2:2013:MsgBody":ReceiptRequired{0-1},"urn:iso:15118:2:2013:MsgBody":AC_EVSEStatus)',  derivedBy='EXTENSION'.  */
static int encode_iso1ChargingStatusResType(bitstream_t* stream, struct iso1ChargingStatusResType* iso1ChargingStatusResType) {
	int grammarID = 144;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 144:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, iso1ChargingStatusResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 145;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 145:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ChargingStatusResType->EVSEID.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1ChargingStatusResType->EVSEID.characters, iso1ChargingStatusResType->EVSEID.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 146;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 146:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SAScheduleTupleID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(iso1ChargingStatusResType->SAScheduleTupleID - 1));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 147;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 147:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaxCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeterInfo), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ReceiptRequired), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AC_EVSEStatus)] */
			if ( iso1ChargingStatusResType->EVSEMaxCurrent_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1ChargingStatusResType->EVSEMaxCurrent );
				}
				grammarID = 148;
			} else 			if ( iso1ChargingStatusResType->MeterInfo_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					errn = encode_iso1MeterInfoType(stream, &iso1ChargingStatusResType->MeterInfo );
				}
				grammarID = 149;
			} else 			if ( iso1ChargingStatusResType->ReceiptRequired_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1ChargingStatusResType->ReceiptRequired);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 150;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					errn = encode_iso1AC_EVSEStatusType(stream, &iso1ChargingStatusResType->AC_EVSEStatus );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 148:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeterInfo), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ReceiptRequired), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AC_EVSEStatus)] */
			if ( iso1ChargingStatusResType->MeterInfo_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1MeterInfoType(stream, &iso1ChargingStatusResType->MeterInfo );
				}
				grammarID = 149;
			} else 			if ( iso1ChargingStatusResType->ReceiptRequired_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1ChargingStatusResType->ReceiptRequired);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 150;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					errn = encode_iso1AC_EVSEStatusType(stream, &iso1ChargingStatusResType->AC_EVSEStatus );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 149:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ReceiptRequired), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AC_EVSEStatus)] */
			if ( iso1ChargingStatusResType->ReceiptRequired_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1ChargingStatusResType->ReceiptRequired);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 150;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1AC_EVSEStatusType(stream, &iso1ChargingStatusResType->AC_EVSEStatus );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 150:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AC_EVSEStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1AC_EVSEStatusType(stream, &iso1ChargingStatusResType->AC_EVSEStatus );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,DSAKeyValueType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='(("http://www.w3.org/2000/09/xmldsig#":P,"http://www.w3.org/2000/09/xmldsig#":Q){0-1},"http://www.w3.org/2000/09/xmldsig#":G{0-1},"http://www.w3.org/2000/09/xmldsig#":Y,"http://www.w3.org/2000/09/xmldsig#":J{0-1},("http://www.w3.org/2000/09/xmldsig#":Seed,"http://www.w3.org/2000/09/xmldsig#":PgenCounter){0-1})',  derivedBy='RESTRICTION'.  */
static int encode_iso1DSAKeyValueType(bitstream_t* stream, struct iso1DSAKeyValueType* iso1DSAKeyValueType) {
	int grammarID = 151;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 151:
			/* FirstStartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}P), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}G), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Y)] */
			if ( iso1DSAKeyValueType->P_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1DSAKeyValueType->P.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1DSAKeyValueType->P.bytes, iso1DSAKeyValueType->P.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 152;
			} else 			if ( iso1DSAKeyValueType->G_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1DSAKeyValueType->G.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1DSAKeyValueType->G.bytes, iso1DSAKeyValueType->G.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 153;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1DSAKeyValueType->Y.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1DSAKeyValueType->Y.bytes, iso1DSAKeyValueType->Y.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 154;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 152:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Q)] */
			if ( iso1DSAKeyValueType->Q_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1DSAKeyValueType->Q.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1DSAKeyValueType->Q.bytes, iso1DSAKeyValueType->Q.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 155;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 155:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}G), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Y)] */
			if ( iso1DSAKeyValueType->G_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1DSAKeyValueType->G.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1DSAKeyValueType->G.bytes, iso1DSAKeyValueType->G.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 153;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1DSAKeyValueType->Y.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1DSAKeyValueType->Y.bytes, iso1DSAKeyValueType->Y.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 154;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 153:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Y)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1DSAKeyValueType->Y.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1DSAKeyValueType->Y.bytes, iso1DSAKeyValueType->Y.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 154;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 154:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}J), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Seed), END_ELEMENT] */
			if ( iso1DSAKeyValueType->J_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1DSAKeyValueType->J.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1DSAKeyValueType->J.bytes, iso1DSAKeyValueType->J.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 156;
			} else 			if ( iso1DSAKeyValueType->Seed_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1DSAKeyValueType->Seed.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1DSAKeyValueType->Seed.bytes, iso1DSAKeyValueType->Seed.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 157;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 156:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Seed), END_ELEMENT] */
			if ( iso1DSAKeyValueType->Seed_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1DSAKeyValueType->Seed.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1DSAKeyValueType->Seed.bytes, iso1DSAKeyValueType->Seed.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 157;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 157:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PgenCounter)] */
			if ( iso1DSAKeyValueType->PgenCounter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1DSAKeyValueType->PgenCounter.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1DSAKeyValueType->PgenCounter.bytes, iso1DSAKeyValueType->PgenCounter.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,ListOfRootCertificateIDsType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":RootCertificateID{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_iso1ListOfRootCertificateIDsType(bitstream_t* stream, struct iso1ListOfRootCertificateIDsType* iso1ListOfRootCertificateIDsType) {
	int grammarID = 158;
	int done = 0;
	
	unsigned int iso1ListOfRootCertificateIDsType_RootCertificateID_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 158:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RootCertificateID)] */
			if (iso1ListOfRootCertificateIDsType_RootCertificateID_currArrayIndex < iso1ListOfRootCertificateIDsType->RootCertificateID.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1X509IssuerSerialType(stream, &iso1ListOfRootCertificateIDsType->RootCertificateID.array [iso1ListOfRootCertificateIDsType_RootCertificateID_currArrayIndex++]);
				}
				grammarID = 159;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 159:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RootCertificateID), END_ELEMENT] */
			if (iso1ListOfRootCertificateIDsType_RootCertificateID_currArrayIndex < iso1ListOfRootCertificateIDsType->RootCertificateID.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1X509IssuerSerialType(stream, &iso1ListOfRootCertificateIDsType->RootCertificateID.array [iso1ListOfRootCertificateIDsType_RootCertificateID_currArrayIndex++]);
				}
				grammarID = 159;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,ChargeServiceType',  base type name='ServiceType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='(("urn:iso:15118:2:2013:MsgDataTypes":ServiceID,"urn:iso:15118:2:2013:MsgDataTypes":ServiceName{0-1},"urn:iso:15118:2:2013:MsgDataTypes":ServiceCategory,"urn:iso:15118:2:2013:MsgDataTypes":ServiceScope{0-1},"urn:iso:15118:2:2013:MsgDataTypes":FreeService),("urn:iso:15118:2:2013:MsgDataTypes":SupportedEnergyTransferMode))',  derivedBy='EXTENSION'.  */
static int encode_iso1ChargeServiceType(bitstream_t* stream, struct iso1ChargeServiceType* iso1ChargeServiceType) {
	int grammarID = 160;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 160:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, iso1ChargeServiceType->ServiceID);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 161;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 161:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceName), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceCategory)] */
			if ( iso1ChargeServiceType->ServiceName_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ChargeServiceType->ServiceName.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1ChargeServiceType->ServiceName.characters, iso1ChargeServiceType->ServiceName.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 162;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, iso1ChargeServiceType->ServiceCategory);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 163;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 162:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceCategory)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, iso1ChargeServiceType->ServiceCategory);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 163;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 163:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceScope), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FreeService)] */
			if ( iso1ChargeServiceType->ServiceScope_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ChargeServiceType->ServiceScope.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1ChargeServiceType->ServiceScope.characters, iso1ChargeServiceType->ServiceScope.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 164;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1ChargeServiceType->FreeService);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 165;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 164:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FreeService)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1ChargeServiceType->FreeService);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 165;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 165:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SupportedEnergyTransferMode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1SupportedEnergyTransferModeType(stream, &iso1ChargeServiceType->SupportedEnergyTransferMode );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,IntervalType',  base type name='anyType',  content type='EMPTY',  isAbstract='true',  hasTypeId='false',  final='0',  block='0',  derivedBy='RESTRICTION'.  */
static int encode_iso1IntervalType(bitstream_t* stream, struct iso1IntervalType* iso1IntervalType) {
	int grammarID = 34;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 34:
			/* FirstStartTag[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,MeteringReceiptReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":SessionID,"urn:iso:15118:2:2013:MsgBody":SAScheduleTupleID{0-1},"urn:iso:15118:2:2013:MsgBody":MeterInfo)',  derivedBy='EXTENSION'.  */
static int encode_iso1MeteringReceiptReqType(bitstream_t* stream, struct iso1MeteringReceiptReqType* iso1MeteringReceiptReqType) {
	int grammarID = 166;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 166:
			/* FirstStartTag[ATTRIBUTE[STRING]({urn:iso:15118:2:2013:MsgBody}Id), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionID)] */
			if ( iso1MeteringReceiptReqType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1MeteringReceiptReqType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1MeteringReceiptReqType->Id.characters, iso1MeteringReceiptReqType->Id.charactersLen);
					}
				}
				grammarID = 167;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_HEX]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1MeteringReceiptReqType->SessionID.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1MeteringReceiptReqType->SessionID.bytes, iso1MeteringReceiptReqType->SessionID.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 168;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 167:
			/* StartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_HEX]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1MeteringReceiptReqType->SessionID.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1MeteringReceiptReqType->SessionID.bytes, iso1MeteringReceiptReqType->SessionID.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 168;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 168:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SAScheduleTupleID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeterInfo)] */
			if ( iso1MeteringReceiptReqType->SAScheduleTupleID_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(iso1MeteringReceiptReqType->SAScheduleTupleID - 1));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 169;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1MeterInfoType(stream, &iso1MeteringReceiptReqType->MeterInfo );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 169:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeterInfo)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1MeterInfoType(stream, &iso1MeteringReceiptReqType->MeterInfo );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,ServiceDetailResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ResponseCode,"urn:iso:15118:2:2013:MsgBody":ServiceID,"urn:iso:15118:2:2013:MsgBody":ServiceParameterList{0-1})',  derivedBy='EXTENSION'.  */
static int encode_iso1ServiceDetailResType(bitstream_t* stream, struct iso1ServiceDetailResType* iso1ServiceDetailResType) {
	int grammarID = 170;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 170:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, iso1ServiceDetailResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 171;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 171:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, iso1ServiceDetailResType->ServiceID);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 172;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 172:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceParameterList), END_ELEMENT] */
			if ( iso1ServiceDetailResType->ServiceParameterList_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ServiceParameterListType(stream, &iso1ServiceDetailResType->ServiceParameterList );
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,KeyValueType',  base type name='anyType',  content type='MIXED',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":DSAKeyValue|"http://www.w3.org/2000/09/xmldsig#":RSAKeyValue|(WC[##other:"http://www.w3.org/2000/09/xmldsig#"]))',  derivedBy='RESTRICTION'.  */
static int encode_iso1KeyValueType(bitstream_t* stream, struct iso1KeyValueType* iso1KeyValueType) {
	int grammarID = 173;
	int done = 0;
	int wcDone = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 173:
			/* FirstStartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DSAKeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RSAKeyValue), START_ELEMENT_GENERIC, CHARACTERS_GENERIC[STRING]] */
			if ( iso1KeyValueType->DSAKeyValue_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_iso1DSAKeyValueType(stream, &iso1KeyValueType->DSAKeyValue );
				}
				grammarID = 174;
			} else 			if ( iso1KeyValueType->RSAKeyValue_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					errn = encode_iso1RSAKeyValueType(stream, &iso1KeyValueType->RSAKeyValue );
				}
				grammarID = 174;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 174;
			} else 			if ( iso1KeyValueType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1KeyValueType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1KeyValueType->ANY.characters, iso1KeyValueType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 175;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 174:
			/* Element[END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if ( iso1KeyValueType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else 			if ( iso1KeyValueType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1KeyValueType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1KeyValueType->ANY.characters, iso1KeyValueType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 174;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 175:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DSAKeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RSAKeyValue), START_ELEMENT_GENERIC, CHARACTERS_GENERIC[STRING]] */
			if ( iso1KeyValueType->DSAKeyValue_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_iso1DSAKeyValueType(stream, &iso1KeyValueType->DSAKeyValue );
				}
				grammarID = 174;
			} else 			if ( iso1KeyValueType->RSAKeyValue_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					errn = encode_iso1RSAKeyValueType(stream, &iso1KeyValueType->RSAKeyValue );
				}
				grammarID = 174;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 174;
			} else 			if ( iso1KeyValueType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1KeyValueType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1KeyValueType->ANY.characters, iso1KeyValueType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 175;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,SelectedServiceListType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":SelectedService{1-16})',  derivedBy='RESTRICTION'.  */
static int encode_iso1SelectedServiceListType(bitstream_t* stream, struct iso1SelectedServiceListType* iso1SelectedServiceListType) {
	int grammarID = 176;
	int done = 0;
	
	unsigned int iso1SelectedServiceListType_SelectedService_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 176:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService)] */
			if (iso1SelectedServiceListType_SelectedService_currArrayIndex < iso1SelectedServiceListType->SelectedService.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1SelectedServiceType(stream, &iso1SelectedServiceListType->SelectedService.array [iso1SelectedServiceListType_SelectedService_currArrayIndex++]);
				}
				grammarID = 177;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 177:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService), END_ELEMENT] */
			if (iso1SelectedServiceListType_SelectedService_currArrayIndex < iso1SelectedServiceListType->SelectedService.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SelectedServiceType(stream, &iso1SelectedServiceListType->SelectedService.array [iso1SelectedServiceListType_SelectedService_currArrayIndex++]);
				}
				grammarID = 178;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 178:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService), END_ELEMENT] */
			if (iso1SelectedServiceListType_SelectedService_currArrayIndex < iso1SelectedServiceListType->SelectedService.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SelectedServiceType(stream, &iso1SelectedServiceListType->SelectedService.array [iso1SelectedServiceListType_SelectedService_currArrayIndex++]);
				}
				grammarID = 179;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 179:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService), END_ELEMENT] */
			if (iso1SelectedServiceListType_SelectedService_currArrayIndex < iso1SelectedServiceListType->SelectedService.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SelectedServiceType(stream, &iso1SelectedServiceListType->SelectedService.array [iso1SelectedServiceListType_SelectedService_currArrayIndex++]);
				}
				grammarID = 180;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 180:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService), END_ELEMENT] */
			if (iso1SelectedServiceListType_SelectedService_currArrayIndex < iso1SelectedServiceListType->SelectedService.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SelectedServiceType(stream, &iso1SelectedServiceListType->SelectedService.array [iso1SelectedServiceListType_SelectedService_currArrayIndex++]);
				}
				grammarID = 181;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 181:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService), END_ELEMENT] */
			if (iso1SelectedServiceListType_SelectedService_currArrayIndex < iso1SelectedServiceListType->SelectedService.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SelectedServiceType(stream, &iso1SelectedServiceListType->SelectedService.array [iso1SelectedServiceListType_SelectedService_currArrayIndex++]);
				}
				grammarID = 182;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 182:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService), END_ELEMENT] */
			if (iso1SelectedServiceListType_SelectedService_currArrayIndex < iso1SelectedServiceListType->SelectedService.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SelectedServiceType(stream, &iso1SelectedServiceListType->SelectedService.array [iso1SelectedServiceListType_SelectedService_currArrayIndex++]);
				}
				grammarID = 183;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 183:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService), END_ELEMENT] */
			if (iso1SelectedServiceListType_SelectedService_currArrayIndex < iso1SelectedServiceListType->SelectedService.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SelectedServiceType(stream, &iso1SelectedServiceListType->SelectedService.array [iso1SelectedServiceListType_SelectedService_currArrayIndex++]);
				}
				grammarID = 184;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 184:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService), END_ELEMENT] */
			if (iso1SelectedServiceListType_SelectedService_currArrayIndex < iso1SelectedServiceListType->SelectedService.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SelectedServiceType(stream, &iso1SelectedServiceListType->SelectedService.array [iso1SelectedServiceListType_SelectedService_currArrayIndex++]);
				}
				grammarID = 185;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 185:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService), END_ELEMENT] */
			if (iso1SelectedServiceListType_SelectedService_currArrayIndex < iso1SelectedServiceListType->SelectedService.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SelectedServiceType(stream, &iso1SelectedServiceListType->SelectedService.array [iso1SelectedServiceListType_SelectedService_currArrayIndex++]);
				}
				grammarID = 186;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 186:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService), END_ELEMENT] */
			if (iso1SelectedServiceListType_SelectedService_currArrayIndex < iso1SelectedServiceListType->SelectedService.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SelectedServiceType(stream, &iso1SelectedServiceListType->SelectedService.array [iso1SelectedServiceListType_SelectedService_currArrayIndex++]);
				}
				grammarID = 187;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 187:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService), END_ELEMENT] */
			if (iso1SelectedServiceListType_SelectedService_currArrayIndex < iso1SelectedServiceListType->SelectedService.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SelectedServiceType(stream, &iso1SelectedServiceListType->SelectedService.array [iso1SelectedServiceListType_SelectedService_currArrayIndex++]);
				}
				grammarID = 188;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 188:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService), END_ELEMENT] */
			if (iso1SelectedServiceListType_SelectedService_currArrayIndex < iso1SelectedServiceListType->SelectedService.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SelectedServiceType(stream, &iso1SelectedServiceListType->SelectedService.array [iso1SelectedServiceListType_SelectedService_currArrayIndex++]);
				}
				grammarID = 189;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 189:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService), END_ELEMENT] */
			if (iso1SelectedServiceListType_SelectedService_currArrayIndex < iso1SelectedServiceListType->SelectedService.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SelectedServiceType(stream, &iso1SelectedServiceListType->SelectedService.array [iso1SelectedServiceListType_SelectedService_currArrayIndex++]);
				}
				grammarID = 190;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 190:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService), END_ELEMENT] */
			if (iso1SelectedServiceListType_SelectedService_currArrayIndex < iso1SelectedServiceListType->SelectedService.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SelectedServiceType(stream, &iso1SelectedServiceListType->SelectedService.array [iso1SelectedServiceListType_SelectedService_currArrayIndex++]);
				}
				grammarID = 191;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 191:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService), END_ELEMENT] */
			if (iso1SelectedServiceListType_SelectedService_currArrayIndex < iso1SelectedServiceListType->SelectedService.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SelectedServiceType(stream, &iso1SelectedServiceListType->SelectedService.array [iso1SelectedServiceListType_SelectedService_currArrayIndex++]);
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,CableCheckResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ResponseCode,"urn:iso:15118:2:2013:MsgBody":DC_EVSEStatus,"urn:iso:15118:2:2013:MsgBody":EVSEProcessing)',  derivedBy='EXTENSION'.  */
static int encode_iso1CableCheckResType(bitstream_t* stream, struct iso1CableCheckResType* iso1CableCheckResType) {
	int grammarID = 192;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 192:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, iso1CableCheckResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 193;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 193:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DC_EVSEStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1DC_EVSEStatusType(stream, &iso1CableCheckResType->DC_EVSEStatus );
				}
				grammarID = 130;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 130:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEProcessing)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, iso1CableCheckResType->EVSEProcessing);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,X509IssuerSerialType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":X509IssuerName,"http://www.w3.org/2000/09/xmldsig#":X509SerialNumber)',  derivedBy='RESTRICTION'.  */
static int encode_iso1X509IssuerSerialType(bitstream_t* stream, struct iso1X509IssuerSerialType* iso1X509IssuerSerialType) {
	int grammarID = 194;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 194:
			/* FirstStartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509IssuerName)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1X509IssuerSerialType->X509IssuerName.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1X509IssuerSerialType->X509IssuerName.characters, iso1X509IssuerSerialType->X509IssuerName.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 195;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 195:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SerialNumber)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* errn = encodeInteger64(stream, iso1X509IssuerSerialType->X509SerialNumber); */
						errn = encodeIntegerBig(stream, iso1X509IssuerSerialType->X509SerialNumber.negative, iso1X509IssuerSerialType_X509SerialNumber_BYTES_SIZE, iso1X509IssuerSerialType->X509SerialNumber.data, iso1X509IssuerSerialType->X509SerialNumber.len);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,KeyInfoType',  base type name='anyType',  content type='MIXED',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":KeyName|"http://www.w3.org/2000/09/xmldsig#":KeyValue|"http://www.w3.org/2000/09/xmldsig#":RetrievalMethod|"http://www.w3.org/2000/09/xmldsig#":X509Data|"http://www.w3.org/2000/09/xmldsig#":PGPData|"http://www.w3.org/2000/09/xmldsig#":SPKIData|"http://www.w3.org/2000/09/xmldsig#":MgmtData|(WC[##other:"http://www.w3.org/2000/09/xmldsig#"])){1-UNBOUNDED}',  derivedBy='RESTRICTION'.  */
static int encode_iso1KeyInfoType(bitstream_t* stream, struct iso1KeyInfoType* iso1KeyInfoType) {
	int grammarID = 196;
	int done = 0;
	int wcDone = 0;
	
	unsigned int iso1KeyInfoType_KeyName_currArrayIndex = 0;
	unsigned int iso1KeyInfoType_KeyValue_currArrayIndex = 0;
	unsigned int iso1KeyInfoType_RetrievalMethod_currArrayIndex = 0;
	unsigned int iso1KeyInfoType_X509Data_currArrayIndex = 0;
	unsigned int iso1KeyInfoType_PGPData_currArrayIndex = 0;
	unsigned int iso1KeyInfoType_SPKIData_currArrayIndex = 0;
	unsigned int iso1KeyInfoType_MgmtData_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 196:
			/* FirstStartTag[ATTRIBUTE[STRING](Id), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RetrievalMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Data), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKIData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}MgmtData), START_ELEMENT_GENERIC, CHARACTERS_GENERIC[STRING]] */
			if ( iso1KeyInfoType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1KeyInfoType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1KeyInfoType->Id.characters, iso1KeyInfoType->Id.charactersLen);
					}
				}
				grammarID = 197;
			} else 			if (iso1KeyInfoType_KeyName_currArrayIndex < iso1KeyInfoType->KeyName.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 1);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1KeyInfoType->KeyName.array[iso1KeyInfoType_KeyName_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1KeyInfoType->KeyName.array[iso1KeyInfoType_KeyName_currArrayIndex].characters, iso1KeyInfoType->KeyName.array[iso1KeyInfoType_KeyName_currArrayIndex].charactersLen);
							iso1KeyInfoType_KeyName_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_KeyValue_currArrayIndex < iso1KeyInfoType->KeyValue.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 2);
				if(errn == 0) {
					errn = encode_iso1KeyValueType(stream, &iso1KeyInfoType->KeyValue.array [iso1KeyInfoType_KeyValue_currArrayIndex++]);
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_RetrievalMethod_currArrayIndex < iso1KeyInfoType->RetrievalMethod.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 3);
				if(errn == 0) {
					errn = encode_iso1RetrievalMethodType(stream, &iso1KeyInfoType->RetrievalMethod.array [iso1KeyInfoType_RetrievalMethod_currArrayIndex++]);
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_X509Data_currArrayIndex < iso1KeyInfoType->X509Data.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 4);
				if(errn == 0) {
					errn = encode_iso1X509DataType(stream, &iso1KeyInfoType->X509Data.array [iso1KeyInfoType_X509Data_currArrayIndex++]);
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_PGPData_currArrayIndex < iso1KeyInfoType->PGPData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 5);
				if(errn == 0) {
					errn = encode_iso1PGPDataType(stream, &iso1KeyInfoType->PGPData.array [iso1KeyInfoType_PGPData_currArrayIndex++]);
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_SPKIData_currArrayIndex < iso1KeyInfoType->SPKIData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 6);
				if(errn == 0) {
					errn = encode_iso1SPKIDataType(stream, &iso1KeyInfoType->SPKIData.array [iso1KeyInfoType_SPKIData_currArrayIndex++]);
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_MgmtData_currArrayIndex < iso1KeyInfoType->MgmtData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 7);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1KeyInfoType->MgmtData.array[iso1KeyInfoType_MgmtData_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1KeyInfoType->MgmtData.array[iso1KeyInfoType_MgmtData_currArrayIndex].characters, iso1KeyInfoType->MgmtData.array[iso1KeyInfoType_MgmtData_currArrayIndex].charactersLen);
							iso1KeyInfoType_MgmtData_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 198;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 198;
			} else 			if ( iso1KeyInfoType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 9);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1KeyInfoType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1KeyInfoType->ANY.characters, iso1KeyInfoType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 199;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 197:
			/* StartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RetrievalMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Data), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKIData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}MgmtData), START_ELEMENT_GENERIC, CHARACTERS_GENERIC[STRING]] */
			if (iso1KeyInfoType_KeyName_currArrayIndex < iso1KeyInfoType->KeyName.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1KeyInfoType->KeyName.array[iso1KeyInfoType_KeyName_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1KeyInfoType->KeyName.array[iso1KeyInfoType_KeyName_currArrayIndex].characters, iso1KeyInfoType->KeyName.array[iso1KeyInfoType_KeyName_currArrayIndex].charactersLen);
							iso1KeyInfoType_KeyName_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_KeyValue_currArrayIndex < iso1KeyInfoType->KeyValue.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 1);
				if(errn == 0) {
					errn = encode_iso1KeyValueType(stream, &iso1KeyInfoType->KeyValue.array [iso1KeyInfoType_KeyValue_currArrayIndex++]);
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_RetrievalMethod_currArrayIndex < iso1KeyInfoType->RetrievalMethod.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 2);
				if(errn == 0) {
					errn = encode_iso1RetrievalMethodType(stream, &iso1KeyInfoType->RetrievalMethod.array [iso1KeyInfoType_RetrievalMethod_currArrayIndex++]);
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_X509Data_currArrayIndex < iso1KeyInfoType->X509Data.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 3);
				if(errn == 0) {
					errn = encode_iso1X509DataType(stream, &iso1KeyInfoType->X509Data.array [iso1KeyInfoType_X509Data_currArrayIndex++]);
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_PGPData_currArrayIndex < iso1KeyInfoType->PGPData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 4);
				if(errn == 0) {
					errn = encode_iso1PGPDataType(stream, &iso1KeyInfoType->PGPData.array [iso1KeyInfoType_PGPData_currArrayIndex++]);
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_SPKIData_currArrayIndex < iso1KeyInfoType->SPKIData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 5);
				if(errn == 0) {
					errn = encode_iso1SPKIDataType(stream, &iso1KeyInfoType->SPKIData.array [iso1KeyInfoType_SPKIData_currArrayIndex++]);
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_MgmtData_currArrayIndex < iso1KeyInfoType->MgmtData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 6);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1KeyInfoType->MgmtData.array[iso1KeyInfoType_MgmtData_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1KeyInfoType->MgmtData.array[iso1KeyInfoType_MgmtData_currArrayIndex].characters, iso1KeyInfoType->MgmtData.array[iso1KeyInfoType_MgmtData_currArrayIndex].charactersLen);
							iso1KeyInfoType_MgmtData_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 198;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 198;
			} else 			if ( iso1KeyInfoType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 8);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1KeyInfoType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1KeyInfoType->ANY.characters, iso1KeyInfoType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 199;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 198:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RetrievalMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Data), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKIData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}MgmtData), START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (iso1KeyInfoType_KeyName_currArrayIndex < iso1KeyInfoType->KeyName.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1KeyInfoType->KeyName.array[iso1KeyInfoType_KeyName_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1KeyInfoType->KeyName.array[iso1KeyInfoType_KeyName_currArrayIndex].characters, iso1KeyInfoType->KeyName.array[iso1KeyInfoType_KeyName_currArrayIndex].charactersLen);
							iso1KeyInfoType_KeyName_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_KeyValue_currArrayIndex < iso1KeyInfoType->KeyValue.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 1);
				if(errn == 0) {
					errn = encode_iso1KeyValueType(stream, &iso1KeyInfoType->KeyValue.array [iso1KeyInfoType_KeyValue_currArrayIndex++]);
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_RetrievalMethod_currArrayIndex < iso1KeyInfoType->RetrievalMethod.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 2);
				if(errn == 0) {
					errn = encode_iso1RetrievalMethodType(stream, &iso1KeyInfoType->RetrievalMethod.array [iso1KeyInfoType_RetrievalMethod_currArrayIndex++]);
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_X509Data_currArrayIndex < iso1KeyInfoType->X509Data.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 3);
				if(errn == 0) {
					errn = encode_iso1X509DataType(stream, &iso1KeyInfoType->X509Data.array [iso1KeyInfoType_X509Data_currArrayIndex++]);
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_PGPData_currArrayIndex < iso1KeyInfoType->PGPData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 4);
				if(errn == 0) {
					errn = encode_iso1PGPDataType(stream, &iso1KeyInfoType->PGPData.array [iso1KeyInfoType_PGPData_currArrayIndex++]);
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_SPKIData_currArrayIndex < iso1KeyInfoType->SPKIData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 5);
				if(errn == 0) {
					errn = encode_iso1SPKIDataType(stream, &iso1KeyInfoType->SPKIData.array [iso1KeyInfoType_SPKIData_currArrayIndex++]);
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_MgmtData_currArrayIndex < iso1KeyInfoType->MgmtData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 6);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1KeyInfoType->MgmtData.array[iso1KeyInfoType_MgmtData_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1KeyInfoType->MgmtData.array[iso1KeyInfoType_MgmtData_currArrayIndex].characters, iso1KeyInfoType->MgmtData.array[iso1KeyInfoType_MgmtData_currArrayIndex].charactersLen);
							iso1KeyInfoType_MgmtData_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 198;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 198;
			} else 			if ( iso1KeyInfoType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 8);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else 			if ( iso1KeyInfoType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 9);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1KeyInfoType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1KeyInfoType->ANY.characters, iso1KeyInfoType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 198;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 199:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RetrievalMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Data), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKIData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}MgmtData), START_ELEMENT_GENERIC, CHARACTERS_GENERIC[STRING]] */
			if (iso1KeyInfoType_KeyName_currArrayIndex < iso1KeyInfoType->KeyName.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1KeyInfoType->KeyName.array[iso1KeyInfoType_KeyName_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1KeyInfoType->KeyName.array[iso1KeyInfoType_KeyName_currArrayIndex].characters, iso1KeyInfoType->KeyName.array[iso1KeyInfoType_KeyName_currArrayIndex].charactersLen);
							iso1KeyInfoType_KeyName_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_KeyValue_currArrayIndex < iso1KeyInfoType->KeyValue.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 1);
				if(errn == 0) {
					errn = encode_iso1KeyValueType(stream, &iso1KeyInfoType->KeyValue.array [iso1KeyInfoType_KeyValue_currArrayIndex++]);
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_RetrievalMethod_currArrayIndex < iso1KeyInfoType->RetrievalMethod.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 2);
				if(errn == 0) {
					errn = encode_iso1RetrievalMethodType(stream, &iso1KeyInfoType->RetrievalMethod.array [iso1KeyInfoType_RetrievalMethod_currArrayIndex++]);
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_X509Data_currArrayIndex < iso1KeyInfoType->X509Data.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 3);
				if(errn == 0) {
					errn = encode_iso1X509DataType(stream, &iso1KeyInfoType->X509Data.array [iso1KeyInfoType_X509Data_currArrayIndex++]);
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_PGPData_currArrayIndex < iso1KeyInfoType->PGPData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 4);
				if(errn == 0) {
					errn = encode_iso1PGPDataType(stream, &iso1KeyInfoType->PGPData.array [iso1KeyInfoType_PGPData_currArrayIndex++]);
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_SPKIData_currArrayIndex < iso1KeyInfoType->SPKIData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 5);
				if(errn == 0) {
					errn = encode_iso1SPKIDataType(stream, &iso1KeyInfoType->SPKIData.array [iso1KeyInfoType_SPKIData_currArrayIndex++]);
				}
				grammarID = 198;
			} else 			if (iso1KeyInfoType_MgmtData_currArrayIndex < iso1KeyInfoType->MgmtData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 6);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1KeyInfoType->MgmtData.array[iso1KeyInfoType_MgmtData_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1KeyInfoType->MgmtData.array[iso1KeyInfoType_MgmtData_currArrayIndex].characters, iso1KeyInfoType->MgmtData.array[iso1KeyInfoType_MgmtData_currArrayIndex].charactersLen);
							iso1KeyInfoType_MgmtData_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 198;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 198;
			} else 			if ( iso1KeyInfoType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 8);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1KeyInfoType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1KeyInfoType->ANY.characters, iso1KeyInfoType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 199;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,TransformsType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":Transform{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_iso1TransformsType(bitstream_t* stream, struct iso1TransformsType* iso1TransformsType) {
	int grammarID = 200;
	int done = 0;
	
	unsigned int iso1TransformsType_Transform_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 200:
			/* FirstStartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transform)] */
			if (iso1TransformsType_Transform_currArrayIndex < iso1TransformsType->Transform.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1TransformType(stream, &iso1TransformsType->Transform.array [iso1TransformsType_Transform_currArrayIndex++]);
				}
				grammarID = 201;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 201:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transform), END_ELEMENT] */
			if (iso1TransformsType_Transform_currArrayIndex < iso1TransformsType->Transform.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1TransformType(stream, &iso1TransformsType->Transform.array [iso1TransformsType_Transform_currArrayIndex++]);
				}
				grammarID = 201;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,ChargeParameterDiscoveryReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":MaxEntriesSAScheduleTuple{0-1},"urn:iso:15118:2:2013:MsgBody":RequestedEnergyTransferMode,"urn:iso:15118:2:2013:MsgDataTypes":EVChargeParameter)',  derivedBy='EXTENSION'.  */
static int encode_iso1ChargeParameterDiscoveryReqType(bitstream_t* stream, struct iso1ChargeParameterDiscoveryReqType* iso1ChargeParameterDiscoveryReqType) {
	int grammarID = 202;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 202:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MaxEntriesSAScheduleTuple), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RequestedEnergyTransferMode)] */
			if ( iso1ChargeParameterDiscoveryReqType->MaxEntriesSAScheduleTuple_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, iso1ChargeParameterDiscoveryReqType->MaxEntriesSAScheduleTuple);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 203;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 3, iso1ChargeParameterDiscoveryReqType->RequestedEnergyTransferMode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 204;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 203:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RequestedEnergyTransferMode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 3, iso1ChargeParameterDiscoveryReqType->RequestedEnergyTransferMode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 204;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 204:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVChargeParameter)] */
			if ( iso1ChargeParameterDiscoveryReqType->AC_EVChargeParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1AC_EVChargeParameterType(stream, &iso1ChargeParameterDiscoveryReqType->AC_EVChargeParameter );
				}
				grammarID = 3;
			} else 			if ( iso1ChargeParameterDiscoveryReqType->DC_EVChargeParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1DC_EVChargeParameterType(stream, &iso1ChargeParameterDiscoveryReqType->DC_EVChargeParameter );
				}
				grammarID = 3;
			} else 			if ( iso1ChargeParameterDiscoveryReqType->EVChargeParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					errn = encode_iso1EVChargeParameterType(stream, &iso1ChargeParameterDiscoveryReqType->EVChargeParameter );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,PreChargeReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":DC_EVStatus,"urn:iso:15118:2:2013:MsgBody":EVTargetVoltage,"urn:iso:15118:2:2013:MsgBody":EVTargetCurrent)',  derivedBy='EXTENSION'.  */
static int encode_iso1PreChargeReqType(bitstream_t* stream, struct iso1PreChargeReqType* iso1PreChargeReqType) {
	int grammarID = 205;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 205:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DC_EVStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1DC_EVStatusType(stream, &iso1PreChargeReqType->DC_EVStatus );
				}
				grammarID = 206;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 206:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVTargetVoltage)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1PreChargeReqType->EVTargetVoltage );
				}
				grammarID = 207;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 207:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVTargetCurrent)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1PreChargeReqType->EVTargetCurrent );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,EVSEStatusType',  base type name='anyType',  content type='ELEMENT',  isAbstract='true',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":NotificationMaxDelay,"urn:iso:15118:2:2013:MsgDataTypes":EVSENotification)',  derivedBy='RESTRICTION'.  */
static int encode_iso1EVSEStatusType(bitstream_t* stream, struct iso1EVSEStatusType* iso1EVSEStatusType) {
	int grammarID = 208;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 208:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}NotificationMaxDelay)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, iso1EVSEStatusType->NotificationMaxDelay);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 209;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 209:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSENotification)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, iso1EVSEStatusType->EVSENotification);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,SignatureMethodType',  base type name='anyType',  content type='MIXED',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":HMACOutputLength{0-1},(WC[##other:"http://www.w3.org/2000/09/xmldsig#"]){0-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_iso1SignatureMethodType(bitstream_t* stream, struct iso1SignatureMethodType* iso1SignatureMethodType) {
	int grammarID = 210;
	int done = 0;
	int wcDone = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 210:
			/* FirstStartTag[ATTRIBUTE[STRING](Algorithm)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SignatureMethodType->Algorithm.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1SignatureMethodType->Algorithm.characters, iso1SignatureMethodType->Algorithm.charactersLen);
					}
				}
				grammarID = 211;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 211:
			/* StartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}HMACOutputLength), START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if ( iso1SignatureMethodType->HMACOutputLength_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger64(stream, iso1SignatureMethodType->HMACOutputLength);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 116;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 116;
			} else 			if ( iso1SignatureMethodType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else 			if ( iso1SignatureMethodType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SignatureMethodType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1SignatureMethodType->ANY.characters, iso1SignatureMethodType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 212;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 116:
			/* Element[START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 116;
			} else 			if ( iso1SignatureMethodType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else 			if ( iso1SignatureMethodType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SignatureMethodType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1SignatureMethodType->ANY.characters, iso1SignatureMethodType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 116;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 212:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}HMACOutputLength), START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if ( iso1SignatureMethodType->HMACOutputLength_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger64(stream, iso1SignatureMethodType->HMACOutputLength);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 116;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 116;
			} else 			if ( iso1SignatureMethodType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else 			if ( iso1SignatureMethodType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SignatureMethodType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1SignatureMethodType->ANY.characters, iso1SignatureMethodType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 212;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,X509DataType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='(("http://www.w3.org/2000/09/xmldsig#":X509IssuerSerial|"http://www.w3.org/2000/09/xmldsig#":X509SKI|"http://www.w3.org/2000/09/xmldsig#":X509SubjectName|"http://www.w3.org/2000/09/xmldsig#":X509Certificate|"http://www.w3.org/2000/09/xmldsig#":X509CRL|(WC[##other:"http://www.w3.org/2000/09/xmldsig#"]))){1-UNBOUNDED}',  derivedBy='RESTRICTION'.  */
static int encode_iso1X509DataType(bitstream_t* stream, struct iso1X509DataType* iso1X509DataType) {
	int grammarID = 213;
	int done = 0;
	int wcDone = 0;
	
	unsigned int iso1X509DataType_X509IssuerSerial_currArrayIndex = 0;
	unsigned int iso1X509DataType_X509SKI_currArrayIndex = 0;
	unsigned int iso1X509DataType_X509SubjectName_currArrayIndex = 0;
	unsigned int iso1X509DataType_X509Certificate_currArrayIndex = 0;
	unsigned int iso1X509DataType_X509CRL_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 213:
			/* FirstStartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509IssuerSerial), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SKI), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SubjectName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Certificate), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509CRL), START_ELEMENT_GENERIC] */
			if (iso1X509DataType_X509IssuerSerial_currArrayIndex < iso1X509DataType->X509IssuerSerial.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_iso1X509IssuerSerialType(stream, &iso1X509DataType->X509IssuerSerial.array [iso1X509DataType_X509IssuerSerial_currArrayIndex++]);
				}
				grammarID = 214;
			} else 			if (iso1X509DataType_X509SKI_currArrayIndex < iso1X509DataType->X509SKI.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1X509DataType->X509SKI.array[iso1X509DataType_X509SKI_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1X509DataType->X509SKI.array[iso1X509DataType_X509SKI_currArrayIndex].bytes, iso1X509DataType->X509SKI.array[iso1X509DataType_X509SKI_currArrayIndex].bytesLen);
							iso1X509DataType_X509SKI_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 214;
			} else 			if (iso1X509DataType_X509SubjectName_currArrayIndex < iso1X509DataType->X509SubjectName.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1X509DataType->X509SubjectName.array[iso1X509DataType_X509SubjectName_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1X509DataType->X509SubjectName.array[iso1X509DataType_X509SubjectName_currArrayIndex].characters, iso1X509DataType->X509SubjectName.array[iso1X509DataType_X509SubjectName_currArrayIndex].charactersLen);
							iso1X509DataType_X509SubjectName_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 214;
			} else 			if (iso1X509DataType_X509Certificate_currArrayIndex < iso1X509DataType->X509Certificate.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1X509DataType->X509Certificate.array[iso1X509DataType_X509Certificate_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1X509DataType->X509Certificate.array[iso1X509DataType_X509Certificate_currArrayIndex].bytes, iso1X509DataType->X509Certificate.array[iso1X509DataType_X509Certificate_currArrayIndex].bytesLen);
							iso1X509DataType_X509Certificate_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 214;
			} else 			if (iso1X509DataType_X509CRL_currArrayIndex < iso1X509DataType->X509CRL.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 4);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1X509DataType->X509CRL.array[iso1X509DataType_X509CRL_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1X509DataType->X509CRL.array[iso1X509DataType_X509CRL_currArrayIndex].bytes, iso1X509DataType->X509CRL.array[iso1X509DataType_X509CRL_currArrayIndex].bytesLen);
							iso1X509DataType_X509CRL_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 214;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 214;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 214:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509IssuerSerial), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SKI), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SubjectName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Certificate), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509CRL), START_ELEMENT_GENERIC, END_ELEMENT] */
			if (iso1X509DataType_X509IssuerSerial_currArrayIndex < iso1X509DataType->X509IssuerSerial.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_iso1X509IssuerSerialType(stream, &iso1X509DataType->X509IssuerSerial.array [iso1X509DataType_X509IssuerSerial_currArrayIndex++]);
				}
				grammarID = 214;
			} else 			if (iso1X509DataType_X509SKI_currArrayIndex < iso1X509DataType->X509SKI.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1X509DataType->X509SKI.array[iso1X509DataType_X509SKI_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1X509DataType->X509SKI.array[iso1X509DataType_X509SKI_currArrayIndex].bytes, iso1X509DataType->X509SKI.array[iso1X509DataType_X509SKI_currArrayIndex].bytesLen);
							iso1X509DataType_X509SKI_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 214;
			} else 			if (iso1X509DataType_X509SubjectName_currArrayIndex < iso1X509DataType->X509SubjectName.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1X509DataType->X509SubjectName.array[iso1X509DataType_X509SubjectName_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1X509DataType->X509SubjectName.array[iso1X509DataType_X509SubjectName_currArrayIndex].characters, iso1X509DataType->X509SubjectName.array[iso1X509DataType_X509SubjectName_currArrayIndex].charactersLen);
							iso1X509DataType_X509SubjectName_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 214;
			} else 			if (iso1X509DataType_X509Certificate_currArrayIndex < iso1X509DataType->X509Certificate.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1X509DataType->X509Certificate.array[iso1X509DataType_X509Certificate_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1X509DataType->X509Certificate.array[iso1X509DataType_X509Certificate_currArrayIndex].bytes, iso1X509DataType->X509Certificate.array[iso1X509DataType_X509Certificate_currArrayIndex].bytesLen);
							iso1X509DataType_X509Certificate_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 214;
			} else 			if (iso1X509DataType_X509CRL_currArrayIndex < iso1X509DataType->X509CRL.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 4);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1X509DataType->X509CRL.array[iso1X509DataType_X509CRL_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1X509DataType->X509CRL.array[iso1X509DataType_X509CRL_currArrayIndex].bytes, iso1X509DataType->X509CRL.array[iso1X509DataType_X509CRL_currArrayIndex].bytesLen);
							iso1X509DataType_X509CRL_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 214;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 214;
			} else 			if ( iso1X509DataType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 6);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,NotificationType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":FaultCode,"urn:iso:15118:2:2013:MsgDataTypes":FaultMsg{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_iso1NotificationType(bitstream_t* stream, struct iso1NotificationType* iso1NotificationType) {
	int grammarID = 215;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 215:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FaultCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, iso1NotificationType->FaultCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 216;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 216:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FaultMsg), END_ELEMENT] */
			if ( iso1NotificationType->FaultMsg_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1NotificationType->FaultMsg.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1NotificationType->FaultMsg.characters, iso1NotificationType->FaultMsg.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,SAScheduleListType',  base type name='SASchedulesType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":SAScheduleTuple{1-3})',  derivedBy='EXTENSION'.  */
static int encode_iso1SAScheduleListType(bitstream_t* stream, struct iso1SAScheduleListType* iso1SAScheduleListType) {
	int grammarID = 217;
	int done = 0;
	
	unsigned int iso1SAScheduleListType_SAScheduleTuple_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 217:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleTuple)] */
			if (iso1SAScheduleListType_SAScheduleTuple_currArrayIndex < iso1SAScheduleListType->SAScheduleTuple.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1SAScheduleTupleType(stream, &iso1SAScheduleListType->SAScheduleTuple.array [iso1SAScheduleListType_SAScheduleTuple_currArrayIndex++]);
				}
				grammarID = 218;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 218:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleTuple), END_ELEMENT] */
			if (iso1SAScheduleListType_SAScheduleTuple_currArrayIndex < iso1SAScheduleListType->SAScheduleTuple.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SAScheduleTupleType(stream, &iso1SAScheduleListType->SAScheduleTuple.array [iso1SAScheduleListType_SAScheduleTuple_currArrayIndex++]);
				}
				grammarID = 219;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 219:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleTuple), END_ELEMENT] */
			if (iso1SAScheduleListType_SAScheduleTuple_currArrayIndex < iso1SAScheduleListType->SAScheduleTuple.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SAScheduleTupleType(stream, &iso1SAScheduleListType->SAScheduleTuple.array [iso1SAScheduleListType_SAScheduleTuple_currArrayIndex++]);
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,BodyType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":BodyElement{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_iso1BodyType(bitstream_t* stream, struct iso1BodyType* iso1BodyType) {
	int grammarID = 220;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 220:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AuthorizationReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AuthorizationRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}BodyElement), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CableCheckReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CableCheckRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateInstallationReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateInstallationRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateUpdateReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateUpdateRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeParameterDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeParameterDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingStatusReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingStatusRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CurrentDemandReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CurrentDemandRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeteringReceiptReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeteringReceiptRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentDetailsReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentDetailsRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentServiceSelectionReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentServiceSelectionRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PowerDeliveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PowerDeliveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PreChargeReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PreChargeRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDetailReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDetailRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionSetupReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionSetupRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionStopReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionStopRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}WeldingDetectionReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}WeldingDetectionRes), END_ELEMENT] */
			if ( iso1BodyType->AuthorizationReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 0);
				if(errn == 0) {
					errn = encode_iso1AuthorizationReqType(stream, &iso1BodyType->AuthorizationReq );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->AuthorizationRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 1);
				if(errn == 0) {
					errn = encode_iso1AuthorizationResType(stream, &iso1BodyType->AuthorizationRes );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->BodyElement_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 2);
				if(errn == 0) {
					errn = encode_iso1BodyBaseType(stream, &iso1BodyType->BodyElement );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->CableCheckReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 3);
				if(errn == 0) {
					errn = encode_iso1CableCheckReqType(stream, &iso1BodyType->CableCheckReq );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->CableCheckRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 4);
				if(errn == 0) {
					errn = encode_iso1CableCheckResType(stream, &iso1BodyType->CableCheckRes );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->CertificateInstallationReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 5);
				if(errn == 0) {
					errn = encode_iso1CertificateInstallationReqType(stream, &iso1BodyType->CertificateInstallationReq );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->CertificateInstallationRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 6);
				if(errn == 0) {
					errn = encode_iso1CertificateInstallationResType(stream, &iso1BodyType->CertificateInstallationRes );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->CertificateUpdateReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 7);
				if(errn == 0) {
					errn = encode_iso1CertificateUpdateReqType(stream, &iso1BodyType->CertificateUpdateReq );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->CertificateUpdateRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 8);
				if(errn == 0) {
					errn = encode_iso1CertificateUpdateResType(stream, &iso1BodyType->CertificateUpdateRes );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->ChargeParameterDiscoveryReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 9);
				if(errn == 0) {
					errn = encode_iso1ChargeParameterDiscoveryReqType(stream, &iso1BodyType->ChargeParameterDiscoveryReq );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->ChargeParameterDiscoveryRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 10);
				if(errn == 0) {
					errn = encode_iso1ChargeParameterDiscoveryResType(stream, &iso1BodyType->ChargeParameterDiscoveryRes );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->ChargingStatusReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 11);
				if(errn == 0) {
					errn = encode_iso1ChargingStatusReqType(stream, &iso1BodyType->ChargingStatusReq );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->ChargingStatusRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 12);
				if(errn == 0) {
					errn = encode_iso1ChargingStatusResType(stream, &iso1BodyType->ChargingStatusRes );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->CurrentDemandReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 13);
				if(errn == 0) {
					errn = encode_iso1CurrentDemandReqType(stream, &iso1BodyType->CurrentDemandReq );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->CurrentDemandRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 14);
				if(errn == 0) {
					errn = encode_iso1CurrentDemandResType(stream, &iso1BodyType->CurrentDemandRes );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->MeteringReceiptReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 15);
				if(errn == 0) {
					errn = encode_iso1MeteringReceiptReqType(stream, &iso1BodyType->MeteringReceiptReq );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->MeteringReceiptRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 16);
				if(errn == 0) {
					errn = encode_iso1MeteringReceiptResType(stream, &iso1BodyType->MeteringReceiptRes );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->PaymentDetailsReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 17);
				if(errn == 0) {
					errn = encode_iso1PaymentDetailsReqType(stream, &iso1BodyType->PaymentDetailsReq );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->PaymentDetailsRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 18);
				if(errn == 0) {
					errn = encode_iso1PaymentDetailsResType(stream, &iso1BodyType->PaymentDetailsRes );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->PaymentServiceSelectionReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 19);
				if(errn == 0) {
					errn = encode_iso1PaymentServiceSelectionReqType(stream, &iso1BodyType->PaymentServiceSelectionReq );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->PaymentServiceSelectionRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 20);
				if(errn == 0) {
					errn = encode_iso1PaymentServiceSelectionResType(stream, &iso1BodyType->PaymentServiceSelectionRes );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->PowerDeliveryReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 21);
				if(errn == 0) {
					errn = encode_iso1PowerDeliveryReqType(stream, &iso1BodyType->PowerDeliveryReq );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->PowerDeliveryRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 22);
				if(errn == 0) {
					errn = encode_iso1PowerDeliveryResType(stream, &iso1BodyType->PowerDeliveryRes );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->PreChargeReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 23);
				if(errn == 0) {
					errn = encode_iso1PreChargeReqType(stream, &iso1BodyType->PreChargeReq );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->PreChargeRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 24);
				if(errn == 0) {
					errn = encode_iso1PreChargeResType(stream, &iso1BodyType->PreChargeRes );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->ServiceDetailReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 25);
				if(errn == 0) {
					errn = encode_iso1ServiceDetailReqType(stream, &iso1BodyType->ServiceDetailReq );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->ServiceDetailRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 26);
				if(errn == 0) {
					errn = encode_iso1ServiceDetailResType(stream, &iso1BodyType->ServiceDetailRes );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->ServiceDiscoveryReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 27);
				if(errn == 0) {
					errn = encode_iso1ServiceDiscoveryReqType(stream, &iso1BodyType->ServiceDiscoveryReq );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->ServiceDiscoveryRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 28);
				if(errn == 0) {
					errn = encode_iso1ServiceDiscoveryResType(stream, &iso1BodyType->ServiceDiscoveryRes );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->SessionSetupReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 29);
				if(errn == 0) {
					errn = encode_iso1SessionSetupReqType(stream, &iso1BodyType->SessionSetupReq );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->SessionSetupRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 30);
				if(errn == 0) {
					errn = encode_iso1SessionSetupResType(stream, &iso1BodyType->SessionSetupRes );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->SessionStopReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 31);
				if(errn == 0) {
					errn = encode_iso1SessionStopReqType(stream, &iso1BodyType->SessionStopReq );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->SessionStopRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 32);
				if(errn == 0) {
					errn = encode_iso1SessionStopResType(stream, &iso1BodyType->SessionStopRes );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->WeldingDetectionReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 33);
				if(errn == 0) {
					errn = encode_iso1WeldingDetectionReqType(stream, &iso1BodyType->WeldingDetectionReq );
				}
				grammarID = 3;
			} else 			if ( iso1BodyType->WeldingDetectionRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 34);
				if(errn == 0) {
					errn = encode_iso1WeldingDetectionResType(stream, &iso1BodyType->WeldingDetectionRes );
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 6, 35);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,ChargingProfileType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":ProfileEntry{1-24})',  derivedBy='RESTRICTION'.  */
static int encode_iso1ChargingProfileType(bitstream_t* stream, struct iso1ChargingProfileType* iso1ChargingProfileType) {
	int grammarID = 221;
	int done = 0;
	
	unsigned int iso1ChargingProfileType_ProfileEntry_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 221:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry)] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 222;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 222:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 223;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 223:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 224;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 224:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 225;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 225:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 226;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 226:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 227;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 227:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 228;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 228:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 229;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 229:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 230;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 230:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 231;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 231:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 232;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 232:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 233;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 233:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 234;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 234:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 235;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 235:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 236;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 236:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 237;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 237:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 238:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 239;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 239:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 240;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 240:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 241;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 241:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 242;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 242:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 243;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 243:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 244;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 244:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (iso1ChargingProfileType_ProfileEntry_currArrayIndex < iso1ChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ProfileEntryType(stream, &iso1ChargingProfileType->ProfileEntry.array [iso1ChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,TransformType',  base type name='anyType',  content type='MIXED',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='((WC[##other:"http://www.w3.org/2000/09/xmldsig#"])|"http://www.w3.org/2000/09/xmldsig#":XPath){0-UNBOUNDED}',  derivedBy='RESTRICTION'.  */
static int encode_iso1TransformType(bitstream_t* stream, struct iso1TransformType* iso1TransformType) {
	int grammarID = 245;
	int done = 0;
	int wcDone = 0;
	
	unsigned int iso1TransformType_XPath_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 245:
			/* FirstStartTag[ATTRIBUTE[STRING](Algorithm)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1TransformType->Algorithm.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1TransformType->Algorithm.characters, iso1TransformType->Algorithm.charactersLen);
					}
				}
				grammarID = 246;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 246:
			/* StartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}XPath), START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (iso1TransformType_XPath_currArrayIndex < iso1TransformType->XPath.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1TransformType->XPath.array[iso1TransformType_XPath_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1TransformType->XPath.array[iso1TransformType_XPath_currArrayIndex].characters, iso1TransformType->XPath.array[iso1TransformType_XPath_currArrayIndex].charactersLen);
							iso1TransformType_XPath_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 247;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 247;
			} else 			if ( iso1TransformType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else 			if ( iso1TransformType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1TransformType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1TransformType->ANY.characters, iso1TransformType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 247;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 247:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}XPath), START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (iso1TransformType_XPath_currArrayIndex < iso1TransformType->XPath.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1TransformType->XPath.array[iso1TransformType_XPath_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1TransformType->XPath.array[iso1TransformType_XPath_currArrayIndex].characters, iso1TransformType->XPath.array[iso1TransformType_XPath_currArrayIndex].charactersLen);
							iso1TransformType_XPath_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 247;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 247;
			} else 			if ( iso1TransformType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else 			if ( iso1TransformType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1TransformType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1TransformType->ANY.characters, iso1TransformType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 247;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,SAScheduleTupleType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":SAScheduleTupleID,"urn:iso:15118:2:2013:MsgDataTypes":PMaxSchedule,"urn:iso:15118:2:2013:MsgDataTypes":SalesTariff{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_iso1SAScheduleTupleType(bitstream_t* stream, struct iso1SAScheduleTupleType* iso1SAScheduleTupleType) {
	int grammarID = 248;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 248:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleTupleID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(iso1SAScheduleTupleType->SAScheduleTupleID - 1));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 249;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 249:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMaxSchedule)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PMaxScheduleType(stream, &iso1SAScheduleTupleType->PMaxSchedule );
				}
				grammarID = 250;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 250:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariff), END_ELEMENT] */
			if ( iso1SAScheduleTupleType->SalesTariff_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SalesTariffType(stream, &iso1SAScheduleTupleType->SalesTariff );
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,AC_EVChargeParameterType',  base type name='EVChargeParameterType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='(("urn:iso:15118:2:2013:MsgDataTypes":DepartureTime{0-1}),("urn:iso:15118:2:2013:MsgDataTypes":EAmount,"urn:iso:15118:2:2013:MsgDataTypes":EVMaxVoltage,"urn:iso:15118:2:2013:MsgDataTypes":EVMaxCurrent,"urn:iso:15118:2:2013:MsgDataTypes":EVMinCurrent))',  derivedBy='EXTENSION'.  */
static int encode_iso1AC_EVChargeParameterType(bitstream_t* stream, struct iso1AC_EVChargeParameterType* iso1AC_EVChargeParameterType) {
	int grammarID = 251;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 251:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DepartureTime), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EAmount)] */
			if ( iso1AC_EVChargeParameterType->DepartureTime_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger32(stream, iso1AC_EVChargeParameterType->DepartureTime);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 252;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1AC_EVChargeParameterType->EAmount );
				}
				grammarID = 253;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 252:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EAmount)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1AC_EVChargeParameterType->EAmount );
				}
				grammarID = 253;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 253:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaxVoltage)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1AC_EVChargeParameterType->EVMaxVoltage );
				}
				grammarID = 254;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 254:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaxCurrent)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1AC_EVChargeParameterType->EVMaxCurrent );
				}
				grammarID = 255;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 255:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMinCurrent)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1AC_EVChargeParameterType->EVMinCurrent );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDef,#AnonType_V2G_Message',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDef":Header,"urn:iso:15118:2:2013:MsgDef":Body)',  derivedBy='RESTRICTION'.  */
static int encode_iso1AnonType_V2G_Message(bitstream_t* stream, struct iso1AnonType_V2G_Message* iso1AnonType_V2G_Message) {
	int grammarID = 256;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 256:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDef}Header)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1MessageHeaderType(stream, &iso1AnonType_V2G_Message->Header );
				}
				grammarID = 257;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 257:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDef}Body)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1BodyType(stream, &iso1AnonType_V2G_Message->Body );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,PaymentDetailsResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ResponseCode,"urn:iso:15118:2:2013:MsgBody":GenChallenge,"urn:iso:15118:2:2013:MsgBody":EVSETimeStamp)',  derivedBy='EXTENSION'.  */
static int encode_iso1PaymentDetailsResType(bitstream_t* stream, struct iso1PaymentDetailsResType* iso1PaymentDetailsResType) {
	int grammarID = 258;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 258:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, iso1PaymentDetailsResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 259;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 259:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}GenChallenge)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1PaymentDetailsResType->GenChallenge.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1PaymentDetailsResType->GenChallenge.bytes, iso1PaymentDetailsResType->GenChallenge.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 260;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 260:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSETimeStamp)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger64(stream, iso1PaymentDetailsResType->EVSETimeStamp);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,ContractSignatureEncryptedPrivateKeyType',  base type name='privateKeyType',  content type='SIMPLE',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  derivedBy='EXTENSION'.  */
static int encode_iso1ContractSignatureEncryptedPrivateKeyType(bitstream_t* stream, struct iso1ContractSignatureEncryptedPrivateKeyType* iso1ContractSignatureEncryptedPrivateKeyType) {
	int grammarID = 23;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 23:
			/* FirstStartTag[ATTRIBUTE[STRING]({urn:iso:15118:2:2013:MsgDataTypes}Id)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ContractSignatureEncryptedPrivateKeyType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1ContractSignatureEncryptedPrivateKeyType->Id.characters, iso1ContractSignatureEncryptedPrivateKeyType->Id.charactersLen);
					}
				}
				grammarID = 24;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 24:
			/* StartTag[CHARACTERS[BINARY_BASE64]] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ContractSignatureEncryptedPrivateKeyType->CONTENT.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, iso1ContractSignatureEncryptedPrivateKeyType->CONTENT.bytes, iso1ContractSignatureEncryptedPrivateKeyType->CONTENT.bytesLen);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,PMaxScheduleEntryType',  base type name='EntryType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='(("urn:iso:15118:2:2013:MsgDataTypes":TimeInterval),("urn:iso:15118:2:2013:MsgDataTypes":PMax))',  derivedBy='EXTENSION'.  */
static int encode_iso1PMaxScheduleEntryType(bitstream_t* stream, struct iso1PMaxScheduleEntryType* iso1PMaxScheduleEntryType) {
	int grammarID = 261;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 261:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RelativeTimeInterval), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}TimeInterval)] */
			if ( iso1PMaxScheduleEntryType->RelativeTimeInterval_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1RelativeTimeIntervalType(stream, &iso1PMaxScheduleEntryType->RelativeTimeInterval );
				}
				grammarID = 262;
			} else 			if ( iso1PMaxScheduleEntryType->TimeInterval_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1IntervalType(stream, &iso1PMaxScheduleEntryType->TimeInterval );
				}
				grammarID = 262;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 262:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMax)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1PMaxScheduleEntryType->PMax );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,SPKIDataType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":SPKISexp,(WC[##other:"http://www.w3.org/2000/09/xmldsig#"]){0-1}){1-UNBOUNDED}',  derivedBy='RESTRICTION'.  */
static int encode_iso1SPKIDataType(bitstream_t* stream, struct iso1SPKIDataType* iso1SPKIDataType) {
	int grammarID = 263;
	int done = 0;
	int wcDone = 0;
	
	unsigned int iso1SPKIDataType_SPKISexp_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 263:
			/* FirstStartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKISexp)] */
			if (iso1SPKIDataType_SPKISexp_currArrayIndex < iso1SPKIDataType->SPKISexp.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SPKIDataType->SPKISexp.array[iso1SPKIDataType_SPKISexp_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1SPKIDataType->SPKISexp.array[iso1SPKIDataType_SPKISexp_currArrayIndex].bytes, iso1SPKIDataType->SPKISexp.array[iso1SPKIDataType_SPKISexp_currArrayIndex].bytesLen);
							iso1SPKIDataType_SPKISexp_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 264;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 264:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKISexp), START_ELEMENT_GENERIC, END_ELEMENT] */
			if (iso1SPKIDataType_SPKISexp_currArrayIndex < iso1SPKIDataType->SPKISexp.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SPKIDataType->SPKISexp.array[iso1SPKIDataType_SPKISexp_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1SPKIDataType->SPKISexp.array[iso1SPKIDataType_SPKISexp_currArrayIndex].bytes, iso1SPKIDataType->SPKISexp.array[iso1SPKIDataType_SPKISexp_currArrayIndex].bytesLen);
							iso1SPKIDataType_SPKISexp_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 264;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 265;
			} else 			if ( iso1SPKIDataType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 265:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKISexp), END_ELEMENT] */
			if (iso1SPKIDataType_SPKISexp_currArrayIndex < iso1SPKIDataType->SPKISexp.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SPKIDataType->SPKISexp.array[iso1SPKIDataType_SPKISexp_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1SPKIDataType->SPKISexp.array[iso1SPKIDataType_SPKISexp_currArrayIndex].bytes, iso1SPKIDataType->SPKISexp.array[iso1SPKIDataType_SPKISexp_currArrayIndex].bytesLen);
							iso1SPKIDataType_SPKISexp_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 264;
			} else 			if ( iso1SPKIDataType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,MeteringReceiptResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ResponseCode,"urn:iso:15118:2:2013:MsgDataTypes":EVSEStatus)',  derivedBy='EXTENSION'.  */
static int encode_iso1MeteringReceiptResType(bitstream_t* stream, struct iso1MeteringReceiptResType* iso1MeteringReceiptResType) {
	int grammarID = 93;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 93:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, iso1MeteringReceiptResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 94;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 94:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEStatus)] */
			if ( iso1MeteringReceiptResType->AC_EVSEStatus_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1AC_EVSEStatusType(stream, &iso1MeteringReceiptResType->AC_EVSEStatus );
				}
				grammarID = 3;
			} else 			if ( iso1MeteringReceiptResType->DC_EVSEStatus_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1DC_EVSEStatusType(stream, &iso1MeteringReceiptResType->DC_EVSEStatus );
				}
				grammarID = 3;
			} else 			if ( iso1MeteringReceiptResType->EVSEStatus_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					errn = encode_iso1EVSEStatusType(stream, &iso1MeteringReceiptResType->EVSEStatus );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,SessionStopReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ChargingSession)',  derivedBy='EXTENSION'.  */
static int encode_iso1SessionStopReqType(bitstream_t* stream, struct iso1SessionStopReqType* iso1SessionStopReqType) {
	int grammarID = 266;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 266:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingSession)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 1, iso1SessionStopReqType->ChargingSession);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,WeldingDetectionResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ResponseCode,"urn:iso:15118:2:2013:MsgBody":DC_EVSEStatus,"urn:iso:15118:2:2013:MsgBody":EVSEPresentVoltage)',  derivedBy='EXTENSION'.  */
static int encode_iso1WeldingDetectionResType(bitstream_t* stream, struct iso1WeldingDetectionResType* iso1WeldingDetectionResType) {
	int grammarID = 39;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 39:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, iso1WeldingDetectionResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 40;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 40:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DC_EVSEStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1DC_EVSEStatusType(stream, &iso1WeldingDetectionResType->DC_EVSEStatus );
				}
				grammarID = 41;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 41:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEPresentVoltage)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1WeldingDetectionResType->EVSEPresentVoltage );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,ReferenceType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":Transforms{0-1},"http://www.w3.org/2000/09/xmldsig#":DigestMethod,"http://www.w3.org/2000/09/xmldsig#":DigestValue)',  derivedBy='RESTRICTION'.  */
static int encode_iso1ReferenceType(bitstream_t* stream, struct iso1ReferenceType* iso1ReferenceType) {
	int grammarID = 267;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 267:
			/* FirstStartTag[ATTRIBUTE[STRING](Id), ATTRIBUTE[STRING](Type), ATTRIBUTE[STRING](URI), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod)] */
			if ( iso1ReferenceType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ReferenceType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1ReferenceType->Id.characters, iso1ReferenceType->Id.charactersLen);
					}
				}
				grammarID = 268;
			} else 			if ( iso1ReferenceType->Type_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ReferenceType->Type.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1ReferenceType->Type.characters, iso1ReferenceType->Type.charactersLen);
					}
				}
				grammarID = 269;
			} else 			if ( iso1ReferenceType->URI_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ReferenceType->URI.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1ReferenceType->URI.characters, iso1ReferenceType->URI.charactersLen);
					}
				}
				grammarID = 270;
			} else 			if ( iso1ReferenceType->Transforms_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					errn = encode_iso1TransformsType(stream, &iso1ReferenceType->Transforms );
				}
				grammarID = 271;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 4);
				if(errn == 0) {
					errn = encode_iso1DigestMethodType(stream, &iso1ReferenceType->DigestMethod );
				}
				grammarID = 272;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 268:
			/* StartTag[ATTRIBUTE[STRING](Type), ATTRIBUTE[STRING](URI), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod)] */
			if ( iso1ReferenceType->Type_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ReferenceType->Type.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1ReferenceType->Type.characters, iso1ReferenceType->Type.charactersLen);
					}
				}
				grammarID = 269;
			} else 			if ( iso1ReferenceType->URI_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ReferenceType->URI.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1ReferenceType->URI.characters, iso1ReferenceType->URI.charactersLen);
					}
				}
				grammarID = 270;
			} else 			if ( iso1ReferenceType->Transforms_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					errn = encode_iso1TransformsType(stream, &iso1ReferenceType->Transforms );
				}
				grammarID = 271;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					errn = encode_iso1DigestMethodType(stream, &iso1ReferenceType->DigestMethod );
				}
				grammarID = 272;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 269:
			/* StartTag[ATTRIBUTE[STRING](URI), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod)] */
			if ( iso1ReferenceType->URI_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ReferenceType->URI.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1ReferenceType->URI.characters, iso1ReferenceType->URI.charactersLen);
					}
				}
				grammarID = 270;
			} else 			if ( iso1ReferenceType->Transforms_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1TransformsType(stream, &iso1ReferenceType->Transforms );
				}
				grammarID = 271;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					errn = encode_iso1DigestMethodType(stream, &iso1ReferenceType->DigestMethod );
				}
				grammarID = 272;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 270:
			/* StartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod)] */
			if ( iso1ReferenceType->Transforms_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1TransformsType(stream, &iso1ReferenceType->Transforms );
				}
				grammarID = 271;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1DigestMethodType(stream, &iso1ReferenceType->DigestMethod );
				}
				grammarID = 272;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 271:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1DigestMethodType(stream, &iso1ReferenceType->DigestMethod );
				}
				grammarID = 272;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 272:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestValue)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ReferenceType->DigestValue.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1ReferenceType->DigestValue.bytes, iso1ReferenceType->DigestValue.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,CurrentDemandReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":DC_EVStatus,"urn:iso:15118:2:2013:MsgBody":EVTargetCurrent,"urn:iso:15118:2:2013:MsgBody":EVMaximumVoltageLimit{0-1},"urn:iso:15118:2:2013:MsgBody":EVMaximumCurrentLimit{0-1},"urn:iso:15118:2:2013:MsgBody":EVMaximumPowerLimit{0-1},"urn:iso:15118:2:2013:MsgBody":BulkChargingComplete{0-1},"urn:iso:15118:2:2013:MsgBody":ChargingComplete,"urn:iso:15118:2:2013:MsgBody":RemainingTimeToFullSoC{0-1},"urn:iso:15118:2:2013:MsgBody":RemainingTimeToBulkSoC{0-1},"urn:iso:15118:2:2013:MsgBody":EVTargetVoltage)',  derivedBy='EXTENSION'.  */
static int encode_iso1CurrentDemandReqType(bitstream_t* stream, struct iso1CurrentDemandReqType* iso1CurrentDemandReqType) {
	int grammarID = 273;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 273:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DC_EVStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1DC_EVStatusType(stream, &iso1CurrentDemandReqType->DC_EVStatus );
				}
				grammarID = 274;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 274:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVTargetCurrent)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandReqType->EVTargetCurrent );
				}
				grammarID = 275;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 275:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}BulkChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingComplete)] */
			if ( iso1CurrentDemandReqType->EVMaximumVoltageLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandReqType->EVMaximumVoltageLimit );
				}
				grammarID = 276;
			} else 			if ( iso1CurrentDemandReqType->EVMaximumCurrentLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandReqType->EVMaximumCurrentLimit );
				}
				grammarID = 277;
			} else 			if ( iso1CurrentDemandReqType->EVMaximumPowerLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandReqType->EVMaximumPowerLimit );
				}
				grammarID = 278;
			} else 			if ( iso1CurrentDemandReqType->BulkChargingComplete_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1CurrentDemandReqType->BulkChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 279;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 4);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1CurrentDemandReqType->ChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 280;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 276:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}BulkChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingComplete)] */
			if ( iso1CurrentDemandReqType->EVMaximumCurrentLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandReqType->EVMaximumCurrentLimit );
				}
				grammarID = 277;
			} else 			if ( iso1CurrentDemandReqType->EVMaximumPowerLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandReqType->EVMaximumPowerLimit );
				}
				grammarID = 278;
			} else 			if ( iso1CurrentDemandReqType->BulkChargingComplete_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1CurrentDemandReqType->BulkChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 279;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1CurrentDemandReqType->ChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 280;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 277:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}BulkChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingComplete)] */
			if ( iso1CurrentDemandReqType->EVMaximumPowerLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandReqType->EVMaximumPowerLimit );
				}
				grammarID = 278;
			} else 			if ( iso1CurrentDemandReqType->BulkChargingComplete_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1CurrentDemandReqType->BulkChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 279;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1CurrentDemandReqType->ChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 280;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 278:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}BulkChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingComplete)] */
			if ( iso1CurrentDemandReqType->BulkChargingComplete_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1CurrentDemandReqType->BulkChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 279;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1CurrentDemandReqType->ChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 280;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 279:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingComplete)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1CurrentDemandReqType->ChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 280;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 280:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RemainingTimeToFullSoC), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RemainingTimeToBulkSoC), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVTargetVoltage)] */
			if ( iso1CurrentDemandReqType->RemainingTimeToFullSoC_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandReqType->RemainingTimeToFullSoC );
				}
				grammarID = 281;
			} else 			if ( iso1CurrentDemandReqType->RemainingTimeToBulkSoC_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandReqType->RemainingTimeToBulkSoC );
				}
				grammarID = 282;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandReqType->EVTargetVoltage );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 281:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RemainingTimeToBulkSoC), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVTargetVoltage)] */
			if ( iso1CurrentDemandReqType->RemainingTimeToBulkSoC_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandReqType->RemainingTimeToBulkSoC );
				}
				grammarID = 282;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandReqType->EVTargetVoltage );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 282:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVTargetVoltage)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandReqType->EVTargetVoltage );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,SalesTariffEntryType',  base type name='EntryType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='(("urn:iso:15118:2:2013:MsgDataTypes":TimeInterval),("urn:iso:15118:2:2013:MsgDataTypes":EPriceLevel{0-1},"urn:iso:15118:2:2013:MsgDataTypes":ConsumptionCost{0-3}))',  derivedBy='EXTENSION'.  */
static int encode_iso1SalesTariffEntryType(bitstream_t* stream, struct iso1SalesTariffEntryType* iso1SalesTariffEntryType) {
	int grammarID = 283;
	int done = 0;
	
	unsigned int iso1SalesTariffEntryType_ConsumptionCost_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 283:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RelativeTimeInterval), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}TimeInterval)] */
			if ( iso1SalesTariffEntryType->RelativeTimeInterval_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1RelativeTimeIntervalType(stream, &iso1SalesTariffEntryType->RelativeTimeInterval );
				}
				grammarID = 284;
			} else 			if ( iso1SalesTariffEntryType->TimeInterval_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1IntervalType(stream, &iso1SalesTariffEntryType->TimeInterval );
				}
				grammarID = 284;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 284:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EPriceLevel), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ConsumptionCost), END_ELEMENT] */
			if ( iso1SalesTariffEntryType->EPriceLevel_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(iso1SalesTariffEntryType->EPriceLevel - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 285;
			} else 			if (iso1SalesTariffEntryType_ConsumptionCost_currArrayIndex < iso1SalesTariffEntryType->ConsumptionCost.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1ConsumptionCostType(stream, &iso1SalesTariffEntryType->ConsumptionCost.array [iso1SalesTariffEntryType_ConsumptionCost_currArrayIndex++]);
				}
				grammarID = 286;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 285:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ConsumptionCost), END_ELEMENT] */
			if (iso1SalesTariffEntryType_ConsumptionCost_currArrayIndex < iso1SalesTariffEntryType->ConsumptionCost.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ConsumptionCostType(stream, &iso1SalesTariffEntryType->ConsumptionCost.array [iso1SalesTariffEntryType_ConsumptionCost_currArrayIndex++]);
				}
				grammarID = 286;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 286:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ConsumptionCost), END_ELEMENT] */
			if (iso1SalesTariffEntryType_ConsumptionCost_currArrayIndex < iso1SalesTariffEntryType->ConsumptionCost.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ConsumptionCostType(stream, &iso1SalesTariffEntryType->ConsumptionCost.array [iso1SalesTariffEntryType_ConsumptionCost_currArrayIndex++]);
				}
				grammarID = 287;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 287:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ConsumptionCost), END_ELEMENT] */
			if (iso1SalesTariffEntryType_ConsumptionCost_currArrayIndex < iso1SalesTariffEntryType->ConsumptionCost.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1ConsumptionCostType(stream, &iso1SalesTariffEntryType->ConsumptionCost.array [iso1SalesTariffEntryType_ConsumptionCost_currArrayIndex++]);
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,EntryType',  base type name='anyType',  content type='ELEMENT',  isAbstract='true',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":TimeInterval)',  derivedBy='RESTRICTION'.  */
static int encode_iso1EntryType(bitstream_t* stream, struct iso1EntryType* iso1EntryType) {
	int grammarID = 288;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 288:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RelativeTimeInterval), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}TimeInterval)] */
			if ( iso1EntryType->RelativeTimeInterval_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1RelativeTimeIntervalType(stream, &iso1EntryType->RelativeTimeInterval );
				}
				grammarID = 3;
			} else 			if ( iso1EntryType->TimeInterval_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1IntervalType(stream, &iso1EntryType->TimeInterval );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,SessionSetupReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":EVCCID)',  derivedBy='EXTENSION'.  */
static int encode_iso1SessionSetupReqType(bitstream_t* stream, struct iso1SessionSetupReqType* iso1SessionSetupReqType) {
	int grammarID = 289;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 289:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVCCID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_HEX]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SessionSetupReqType->EVCCID.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1SessionSetupReqType->EVCCID.bytes, iso1SessionSetupReqType->EVCCID.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,CostType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":costKind,"urn:iso:15118:2:2013:MsgDataTypes":amount,"urn:iso:15118:2:2013:MsgDataTypes":amountMultiplier{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_iso1CostType(bitstream_t* stream, struct iso1CostType* iso1CostType) {
	int grammarID = 290;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 290:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}costKind)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, iso1CostType->costKind);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 291;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 291:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}amount)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger32(stream, iso1CostType->amount);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 292;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 292:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}amountMultiplier), END_ELEMENT] */
			if ( iso1CostType->amountMultiplier_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 3, (uint32_t)(iso1CostType->amountMultiplier + 3));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,DC_EVPowerDeliveryParameterType',  base type name='EVPowerDeliveryParameterType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":DC_EVStatus,"urn:iso:15118:2:2013:MsgDataTypes":BulkChargingComplete{0-1},"urn:iso:15118:2:2013:MsgDataTypes":ChargingComplete)',  derivedBy='EXTENSION'.  */
static int encode_iso1DC_EVPowerDeliveryParameterType(bitstream_t* stream, struct iso1DC_EVPowerDeliveryParameterType* iso1DC_EVPowerDeliveryParameterType) {
	int grammarID = 293;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 293:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1DC_EVStatusType(stream, &iso1DC_EVPowerDeliveryParameterType->DC_EVStatus );
				}
				grammarID = 294;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 294:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}BulkChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingComplete)] */
			if ( iso1DC_EVPowerDeliveryParameterType->BulkChargingComplete_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1DC_EVPowerDeliveryParameterType->BulkChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 295;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1DC_EVPowerDeliveryParameterType->ChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 295:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingComplete)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1DC_EVPowerDeliveryParameterType->ChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,RetrievalMethodType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":Transforms{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_iso1RetrievalMethodType(bitstream_t* stream, struct iso1RetrievalMethodType* iso1RetrievalMethodType) {
	int grammarID = 296;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 296:
			/* FirstStartTag[ATTRIBUTE[STRING](Type), ATTRIBUTE[STRING](URI), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), END_ELEMENT] */
			if ( iso1RetrievalMethodType->Type_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1RetrievalMethodType->Type.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1RetrievalMethodType->Type.characters, iso1RetrievalMethodType->Type.charactersLen);
					}
				}
				grammarID = 297;
			} else 			if ( iso1RetrievalMethodType->URI_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1RetrievalMethodType->URI.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1RetrievalMethodType->URI.characters, iso1RetrievalMethodType->URI.charactersLen);
					}
				}
				grammarID = 298;
			} else 			if ( iso1RetrievalMethodType->Transforms_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					errn = encode_iso1TransformsType(stream, &iso1RetrievalMethodType->Transforms );
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 297:
			/* StartTag[ATTRIBUTE[STRING](URI), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), END_ELEMENT] */
			if ( iso1RetrievalMethodType->URI_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1RetrievalMethodType->URI.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1RetrievalMethodType->URI.characters, iso1RetrievalMethodType->URI.charactersLen);
					}
				}
				grammarID = 298;
			} else 			if ( iso1RetrievalMethodType->Transforms_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1TransformsType(stream, &iso1RetrievalMethodType->Transforms );
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 298:
			/* StartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), END_ELEMENT] */
			if ( iso1RetrievalMethodType->Transforms_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1TransformsType(stream, &iso1RetrievalMethodType->Transforms );
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,CertificateUpdateResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ResponseCode,"urn:iso:15118:2:2013:MsgBody":SAProvisioningCertificateChain,"urn:iso:15118:2:2013:MsgBody":ContractSignatureCertChain,"urn:iso:15118:2:2013:MsgBody":ContractSignatureEncryptedPrivateKey,"urn:iso:15118:2:2013:MsgBody":DHpublickey,"urn:iso:15118:2:2013:MsgBody":eMAID,"urn:iso:15118:2:2013:MsgBody":RetryCounter{0-1})',  derivedBy='EXTENSION'.  */
static int encode_iso1CertificateUpdateResType(bitstream_t* stream, struct iso1CertificateUpdateResType* iso1CertificateUpdateResType) {
	int grammarID = 299;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 299:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, iso1CertificateUpdateResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 300;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 300:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SAProvisioningCertificateChain)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1CertificateChainType(stream, &iso1CertificateUpdateResType->SAProvisioningCertificateChain );
				}
				grammarID = 301;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 301:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ContractSignatureCertChain)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1CertificateChainType(stream, &iso1CertificateUpdateResType->ContractSignatureCertChain );
				}
				grammarID = 302;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 302:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ContractSignatureEncryptedPrivateKey)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1ContractSignatureEncryptedPrivateKeyType(stream, &iso1CertificateUpdateResType->ContractSignatureEncryptedPrivateKey );
				}
				grammarID = 303;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 303:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DHpublickey)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1DiffieHellmanPublickeyType(stream, &iso1CertificateUpdateResType->DHpublickey );
				}
				grammarID = 304;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 304:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}eMAID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1EMAIDType(stream, &iso1CertificateUpdateResType->eMAID );
				}
				grammarID = 305;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 305:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RetryCounter), END_ELEMENT] */
			if ( iso1CertificateUpdateResType->RetryCounter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, iso1CertificateUpdateResType->RetryCounter);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,CertificateInstallationResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ResponseCode,"urn:iso:15118:2:2013:MsgBody":SAProvisioningCertificateChain,"urn:iso:15118:2:2013:MsgBody":ContractSignatureCertChain,"urn:iso:15118:2:2013:MsgBody":ContractSignatureEncryptedPrivateKey,"urn:iso:15118:2:2013:MsgBody":DHpublickey,"urn:iso:15118:2:2013:MsgBody":eMAID)',  derivedBy='EXTENSION'.  */
static int encode_iso1CertificateInstallationResType(bitstream_t* stream, struct iso1CertificateInstallationResType* iso1CertificateInstallationResType) {
	int grammarID = 306;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 306:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, iso1CertificateInstallationResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 307;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 307:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SAProvisioningCertificateChain)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1CertificateChainType(stream, &iso1CertificateInstallationResType->SAProvisioningCertificateChain );
				}
				grammarID = 308;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 308:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ContractSignatureCertChain)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1CertificateChainType(stream, &iso1CertificateInstallationResType->ContractSignatureCertChain );
				}
				grammarID = 309;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 309:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ContractSignatureEncryptedPrivateKey)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1ContractSignatureEncryptedPrivateKeyType(stream, &iso1CertificateInstallationResType->ContractSignatureEncryptedPrivateKey );
				}
				grammarID = 310;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 310:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DHpublickey)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1DiffieHellmanPublickeyType(stream, &iso1CertificateInstallationResType->DHpublickey );
				}
				grammarID = 311;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 311:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}eMAID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1EMAIDType(stream, &iso1CertificateInstallationResType->eMAID );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,CanonicalizationMethodType',  base type name='anyType',  content type='MIXED',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='((WC[##any]){0-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_iso1CanonicalizationMethodType(bitstream_t* stream, struct iso1CanonicalizationMethodType* iso1CanonicalizationMethodType) {
	int grammarID = 312;
	int done = 0;
	int wcDone = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 312:
			/* FirstStartTag[ATTRIBUTE[STRING](Algorithm)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1CanonicalizationMethodType->Algorithm.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1CanonicalizationMethodType->Algorithm.characters, iso1CanonicalizationMethodType->Algorithm.charactersLen);
					}
				}
				grammarID = 115;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 115:
			/* StartTag[START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 116;
			} else 			if ( iso1CanonicalizationMethodType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else 			if ( iso1CanonicalizationMethodType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1CanonicalizationMethodType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1CanonicalizationMethodType->ANY.characters, iso1CanonicalizationMethodType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 116;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 116:
			/* Element[START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 116;
			} else 			if ( iso1CanonicalizationMethodType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else 			if ( iso1CanonicalizationMethodType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1CanonicalizationMethodType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1CanonicalizationMethodType->ANY.characters, iso1CanonicalizationMethodType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 116;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,WeldingDetectionReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":DC_EVStatus)',  derivedBy='EXTENSION'.  */
static int encode_iso1WeldingDetectionReqType(bitstream_t* stream, struct iso1WeldingDetectionReqType* iso1WeldingDetectionReqType) {
	int grammarID = 313;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 313:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DC_EVStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1DC_EVStatusType(stream, &iso1WeldingDetectionReqType->DC_EVStatus );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,DC_EVStatusType',  base type name='EVStatusType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":EVReady,"urn:iso:15118:2:2013:MsgDataTypes":EVErrorCode,"urn:iso:15118:2:2013:MsgDataTypes":EVRESSSOC)',  derivedBy='EXTENSION'.  */
static int encode_iso1DC_EVStatusType(bitstream_t* stream, struct iso1DC_EVStatusType* iso1DC_EVStatusType) {
	int grammarID = 314;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 314:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVReady)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1DC_EVStatusType->EVReady);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 315;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 315:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVErrorCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 4, iso1DC_EVStatusType->EVErrorCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 316;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 316:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVRESSSOC)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(iso1DC_EVStatusType->EVRESSSOC - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,CurrentDemandResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ResponseCode,"urn:iso:15118:2:2013:MsgBody":DC_EVSEStatus,"urn:iso:15118:2:2013:MsgBody":EVSEPresentVoltage,"urn:iso:15118:2:2013:MsgBody":EVSEPresentCurrent,"urn:iso:15118:2:2013:MsgBody":EVSECurrentLimitAchieved,"urn:iso:15118:2:2013:MsgBody":EVSEVoltageLimitAchieved,"urn:iso:15118:2:2013:MsgBody":EVSEPowerLimitAchieved,"urn:iso:15118:2:2013:MsgBody":EVSEMaximumVoltageLimit{0-1},"urn:iso:15118:2:2013:MsgBody":EVSEMaximumCurrentLimit{0-1},"urn:iso:15118:2:2013:MsgBody":EVSEMaximumPowerLimit{0-1},"urn:iso:15118:2:2013:MsgBody":EVSEID,"urn:iso:15118:2:2013:MsgBody":SAScheduleTupleID,"urn:iso:15118:2:2013:MsgBody":MeterInfo{0-1},"urn:iso:15118:2:2013:MsgBody":ReceiptRequired{0-1})',  derivedBy='EXTENSION'.  */
static int encode_iso1CurrentDemandResType(bitstream_t* stream, struct iso1CurrentDemandResType* iso1CurrentDemandResType) {
	int grammarID = 317;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 317:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, iso1CurrentDemandResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 318;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 318:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DC_EVSEStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1DC_EVSEStatusType(stream, &iso1CurrentDemandResType->DC_EVSEStatus );
				}
				grammarID = 319;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 319:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEPresentVoltage)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandResType->EVSEPresentVoltage );
				}
				grammarID = 320;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 320:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEPresentCurrent)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandResType->EVSEPresentCurrent );
				}
				grammarID = 321;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 321:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSECurrentLimitAchieved)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1CurrentDemandResType->EVSECurrentLimitAchieved);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 322;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 322:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEVoltageLimitAchieved)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1CurrentDemandResType->EVSEVoltageLimitAchieved);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 323;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 323:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEPowerLimitAchieved)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1CurrentDemandResType->EVSEPowerLimitAchieved);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 324;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 324:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEID)] */
			if ( iso1CurrentDemandResType->EVSEMaximumVoltageLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandResType->EVSEMaximumVoltageLimit );
				}
				grammarID = 325;
			} else 			if ( iso1CurrentDemandResType->EVSEMaximumCurrentLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandResType->EVSEMaximumCurrentLimit );
				}
				grammarID = 326;
			} else 			if ( iso1CurrentDemandResType->EVSEMaximumPowerLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandResType->EVSEMaximumPowerLimit );
				}
				grammarID = 327;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1CurrentDemandResType->EVSEID.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1CurrentDemandResType->EVSEID.characters, iso1CurrentDemandResType->EVSEID.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 328;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 325:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEID)] */
			if ( iso1CurrentDemandResType->EVSEMaximumCurrentLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandResType->EVSEMaximumCurrentLimit );
				}
				grammarID = 326;
			} else 			if ( iso1CurrentDemandResType->EVSEMaximumPowerLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandResType->EVSEMaximumPowerLimit );
				}
				grammarID = 327;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1CurrentDemandResType->EVSEID.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1CurrentDemandResType->EVSEID.characters, iso1CurrentDemandResType->EVSEID.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 328;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 326:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEID)] */
			if ( iso1CurrentDemandResType->EVSEMaximumPowerLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1CurrentDemandResType->EVSEMaximumPowerLimit );
				}
				grammarID = 327;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1CurrentDemandResType->EVSEID.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1CurrentDemandResType->EVSEID.characters, iso1CurrentDemandResType->EVSEID.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 328;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 327:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1CurrentDemandResType->EVSEID.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1CurrentDemandResType->EVSEID.characters, iso1CurrentDemandResType->EVSEID.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 328;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 328:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SAScheduleTupleID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(iso1CurrentDemandResType->SAScheduleTupleID - 1));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 329;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 329:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeterInfo), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ReceiptRequired), END_ELEMENT] */
			if ( iso1CurrentDemandResType->MeterInfo_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1MeterInfoType(stream, &iso1CurrentDemandResType->MeterInfo );
				}
				grammarID = 330;
			} else 			if ( iso1CurrentDemandResType->ReceiptRequired_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1CurrentDemandResType->ReceiptRequired);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 330:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ReceiptRequired), END_ELEMENT] */
			if ( iso1CurrentDemandResType->ReceiptRequired_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1CurrentDemandResType->ReceiptRequired);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,ServiceType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":ServiceID,"urn:iso:15118:2:2013:MsgDataTypes":ServiceName{0-1},"urn:iso:15118:2:2013:MsgDataTypes":ServiceCategory,"urn:iso:15118:2:2013:MsgDataTypes":ServiceScope{0-1},"urn:iso:15118:2:2013:MsgDataTypes":FreeService)',  derivedBy='RESTRICTION'.  */
static int encode_iso1ServiceType(bitstream_t* stream, struct iso1ServiceType* iso1ServiceType) {
	int grammarID = 331;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 331:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, iso1ServiceType->ServiceID);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 332;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 332:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceName), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceCategory)] */
			if ( iso1ServiceType->ServiceName_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ServiceType->ServiceName.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1ServiceType->ServiceName.characters, iso1ServiceType->ServiceName.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 333;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, iso1ServiceType->ServiceCategory);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 334;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 333:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceCategory)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, iso1ServiceType->ServiceCategory);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 334;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 334:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceScope), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FreeService)] */
			if ( iso1ServiceType->ServiceScope_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ServiceType->ServiceScope.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1ServiceType->ServiceScope.characters, iso1ServiceType->ServiceScope.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 335;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1ServiceType->FreeService);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 335:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FreeService)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1ServiceType->FreeService);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,ServiceDiscoveryReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ServiceScope{0-1},"urn:iso:15118:2:2013:MsgBody":ServiceCategory{0-1})',  derivedBy='EXTENSION'.  */
static int encode_iso1ServiceDiscoveryReqType(bitstream_t* stream, struct iso1ServiceDiscoveryReqType* iso1ServiceDiscoveryReqType) {
	int grammarID = 336;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 336:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceScope), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceCategory), END_ELEMENT] */
			if ( iso1ServiceDiscoveryReqType->ServiceScope_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1ServiceDiscoveryReqType->ServiceScope.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1ServiceDiscoveryReqType->ServiceScope.characters, iso1ServiceDiscoveryReqType->ServiceScope.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 337;
			} else 			if ( iso1ServiceDiscoveryReqType->ServiceCategory_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, iso1ServiceDiscoveryReqType->ServiceCategory);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 337:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceCategory), END_ELEMENT] */
			if ( iso1ServiceDiscoveryReqType->ServiceCategory_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, iso1ServiceDiscoveryReqType->ServiceCategory);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,AC_EVSEChargeParameterType',  base type name='EVSEChargeParameterType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":AC_EVSEStatus,"urn:iso:15118:2:2013:MsgDataTypes":EVSENominalVoltage,"urn:iso:15118:2:2013:MsgDataTypes":EVSEMaxCurrent)',  derivedBy='EXTENSION'.  */
static int encode_iso1AC_EVSEChargeParameterType(bitstream_t* stream, struct iso1AC_EVSEChargeParameterType* iso1AC_EVSEChargeParameterType) {
	int grammarID = 338;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 338:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1AC_EVSEStatusType(stream, &iso1AC_EVSEChargeParameterType->AC_EVSEStatus );
				}
				grammarID = 339;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 339:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSENominalVoltage)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1AC_EVSEChargeParameterType->EVSENominalVoltage );
				}
				grammarID = 340;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 340:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaxCurrent)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1PhysicalValueType(stream, &iso1AC_EVSEChargeParameterType->EVSEMaxCurrent );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,CableCheckReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":DC_EVStatus)',  derivedBy='EXTENSION'.  */
static int encode_iso1CableCheckReqType(bitstream_t* stream, struct iso1CableCheckReqType* iso1CableCheckReqType) {
	int grammarID = 313;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 313:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DC_EVStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1DC_EVStatusType(stream, &iso1CableCheckReqType->DC_EVStatus );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,SelectedServiceType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":ServiceID,"urn:iso:15118:2:2013:MsgDataTypes":ParameterSetID{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_iso1SelectedServiceType(bitstream_t* stream, struct iso1SelectedServiceType* iso1SelectedServiceType) {
	int grammarID = 341;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 341:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, iso1SelectedServiceType->ServiceID);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 342;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 342:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ParameterSetID), END_ELEMENT] */
			if ( iso1SelectedServiceType->ParameterSetID_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, iso1SelectedServiceType->ParameterSetID);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,AC_EVSEStatusType',  base type name='EVSEStatusType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='(("urn:iso:15118:2:2013:MsgDataTypes":NotificationMaxDelay,"urn:iso:15118:2:2013:MsgDataTypes":EVSENotification),("urn:iso:15118:2:2013:MsgDataTypes":RCD))',  derivedBy='EXTENSION'.  */
static int encode_iso1AC_EVSEStatusType(bitstream_t* stream, struct iso1AC_EVSEStatusType* iso1AC_EVSEStatusType) {
	int grammarID = 343;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 343:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}NotificationMaxDelay)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, iso1AC_EVSEStatusType->NotificationMaxDelay);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 344;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 344:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSENotification)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, iso1AC_EVSEStatusType->EVSENotification);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 345;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 345:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RCD)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, iso1AC_EVSEStatusType->RCD);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,SalesTariffType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":SalesTariffID,"urn:iso:15118:2:2013:MsgDataTypes":SalesTariffDescription{0-1},"urn:iso:15118:2:2013:MsgDataTypes":NumEPriceLevels{0-1},"urn:iso:15118:2:2013:MsgDataTypes":SalesTariffEntry{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_iso1SalesTariffType(bitstream_t* stream, struct iso1SalesTariffType* iso1SalesTariffType) {
	int grammarID = 346;
	int done = 0;
	
	unsigned int iso1SalesTariffType_SalesTariffEntry_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 346:
			/* FirstStartTag[ATTRIBUTE[STRING]({urn:iso:15118:2:2013:MsgDataTypes}Id), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffID)] */
			if ( iso1SalesTariffType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SalesTariffType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1SalesTariffType->Id.characters, iso1SalesTariffType->Id.charactersLen);
					}
				}
				grammarID = 347;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(iso1SalesTariffType->SalesTariffID - 1));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 348;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 347:
			/* StartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(iso1SalesTariffType->SalesTariffID - 1));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 348;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 348:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffDescription), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}NumEPriceLevels), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffEntry)] */
			if ( iso1SalesTariffType->SalesTariffDescription_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SalesTariffType->SalesTariffDescription.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, iso1SalesTariffType->SalesTariffDescription.characters, iso1SalesTariffType->SalesTariffDescription.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 349;
			} else 			if ( iso1SalesTariffType->NumEPriceLevels_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(iso1SalesTariffType->NumEPriceLevels - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 350;
			} else 			if (iso1SalesTariffType_SalesTariffEntry_currArrayIndex < iso1SalesTariffType->SalesTariffEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					errn = encode_iso1SalesTariffEntryType(stream, &iso1SalesTariffType->SalesTariffEntry.array [iso1SalesTariffType_SalesTariffEntry_currArrayIndex++]);
				}
				grammarID = 351;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 349:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}NumEPriceLevels), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffEntry)] */
			if ( iso1SalesTariffType->NumEPriceLevels_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(iso1SalesTariffType->NumEPriceLevels - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 350;
			} else 			if (iso1SalesTariffType_SalesTariffEntry_currArrayIndex < iso1SalesTariffType->SalesTariffEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1SalesTariffEntryType(stream, &iso1SalesTariffType->SalesTariffEntry.array [iso1SalesTariffType_SalesTariffEntry_currArrayIndex++]);
				}
				grammarID = 351;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 350:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffEntry)] */
			if (iso1SalesTariffType_SalesTariffEntry_currArrayIndex < iso1SalesTariffType->SalesTariffEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1SalesTariffEntryType(stream, &iso1SalesTariffType->SalesTariffEntry.array [iso1SalesTariffType_SalesTariffEntry_currArrayIndex++]);
				}
				grammarID = 351;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 351:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffEntry), END_ELEMENT] */
			if (iso1SalesTariffType_SalesTariffEntry_currArrayIndex < iso1SalesTariffType->SalesTariffEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SalesTariffEntryType(stream, &iso1SalesTariffType->SalesTariffEntry.array [iso1SalesTariffType_SalesTariffEntry_currArrayIndex++]);
				}
				grammarID = 351;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,PaymentServiceSelectionReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":SelectedPaymentOption,"urn:iso:15118:2:2013:MsgBody":SelectedServiceList)',  derivedBy='EXTENSION'.  */
static int encode_iso1PaymentServiceSelectionReqType(bitstream_t* stream, struct iso1PaymentServiceSelectionReqType* iso1PaymentServiceSelectionReqType) {
	int grammarID = 352;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 352:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SelectedPaymentOption)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 1, iso1PaymentServiceSelectionReqType->SelectedPaymentOption);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 353;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 353:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SelectedServiceList)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1SelectedServiceListType(stream, &iso1PaymentServiceSelectionReqType->SelectedServiceList );
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,SignaturePropertiesType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":SignatureProperty{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_iso1SignaturePropertiesType(bitstream_t* stream, struct iso1SignaturePropertiesType* iso1SignaturePropertiesType) {
	int grammarID = 354;
	int done = 0;
	
	unsigned int iso1SignaturePropertiesType_SignatureProperty_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 354:
			/* FirstStartTag[ATTRIBUTE[STRING](Id), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperty)] */
			if ( iso1SignaturePropertiesType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SignaturePropertiesType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1SignaturePropertiesType->Id.characters, iso1SignaturePropertiesType->Id.charactersLen);
					}
				}
				grammarID = 355;
			} else 			if (iso1SignaturePropertiesType_SignatureProperty_currArrayIndex < iso1SignaturePropertiesType->SignatureProperty.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_iso1SignaturePropertyType(stream, &iso1SignaturePropertiesType->SignatureProperty.array [iso1SignaturePropertiesType_SignatureProperty_currArrayIndex++]);
				}
				grammarID = 356;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 355:
			/* StartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperty)] */
			if (iso1SignaturePropertiesType_SignatureProperty_currArrayIndex < iso1SignaturePropertiesType->SignatureProperty.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_iso1SignaturePropertyType(stream, &iso1SignaturePropertiesType->SignatureProperty.array [iso1SignaturePropertiesType_SignatureProperty_currArrayIndex++]);
				}
				grammarID = 356;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 356:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperty), END_ELEMENT] */
			if (iso1SignaturePropertiesType_SignatureProperty_currArrayIndex < iso1SignaturePropertiesType->SignatureProperty.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_iso1SignaturePropertyType(stream, &iso1SignaturePropertiesType->SignatureProperty.array [iso1SignaturePropertiesType_SignatureProperty_currArrayIndex++]);
				}
				grammarID = 356;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,BodyBaseType',  base type name='anyType',  content type='EMPTY',  isAbstract='true',  hasTypeId='false',  final='0',  block='0',  derivedBy='RESTRICTION'.  */
static int encode_iso1BodyBaseType(bitstream_t* stream, struct iso1BodyBaseType* iso1BodyBaseType) {
	int grammarID = 34;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 34:
			/* FirstStartTag[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgDataTypes,SupportedEnergyTransferModeType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgDataTypes":EnergyTransferMode{1-6})',  derivedBy='RESTRICTION'.  */
static int encode_iso1SupportedEnergyTransferModeType(bitstream_t* stream, struct iso1SupportedEnergyTransferModeType* iso1SupportedEnergyTransferModeType) {
	int grammarID = 357;
	int done = 0;
	
	unsigned int iso1SupportedEnergyTransferModeType_EnergyTransferMode_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 357:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EnergyTransferMode)] */
			if (iso1SupportedEnergyTransferModeType_EnergyTransferMode_currArrayIndex < iso1SupportedEnergyTransferModeType->EnergyTransferMode.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 3, iso1SupportedEnergyTransferModeType->EnergyTransferMode.array[iso1SupportedEnergyTransferModeType_EnergyTransferMode_currArrayIndex++]);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 358;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 358:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EnergyTransferMode), END_ELEMENT] */
			if (iso1SupportedEnergyTransferModeType_EnergyTransferMode_currArrayIndex < iso1SupportedEnergyTransferModeType->EnergyTransferMode.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 3, iso1SupportedEnergyTransferModeType->EnergyTransferMode.array[iso1SupportedEnergyTransferModeType_EnergyTransferMode_currArrayIndex++]);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 359;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 359:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EnergyTransferMode), END_ELEMENT] */
			if (iso1SupportedEnergyTransferModeType_EnergyTransferMode_currArrayIndex < iso1SupportedEnergyTransferModeType->EnergyTransferMode.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 3, iso1SupportedEnergyTransferModeType->EnergyTransferMode.array[iso1SupportedEnergyTransferModeType_EnergyTransferMode_currArrayIndex++]);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 360;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 360:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EnergyTransferMode), END_ELEMENT] */
			if (iso1SupportedEnergyTransferModeType_EnergyTransferMode_currArrayIndex < iso1SupportedEnergyTransferModeType->EnergyTransferMode.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 3, iso1SupportedEnergyTransferModeType->EnergyTransferMode.array[iso1SupportedEnergyTransferModeType_EnergyTransferMode_currArrayIndex++]);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 361;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 361:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EnergyTransferMode), END_ELEMENT] */
			if (iso1SupportedEnergyTransferModeType_EnergyTransferMode_currArrayIndex < iso1SupportedEnergyTransferModeType->EnergyTransferMode.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 3, iso1SupportedEnergyTransferModeType->EnergyTransferMode.array[iso1SupportedEnergyTransferModeType_EnergyTransferMode_currArrayIndex++]);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 362;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 362:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EnergyTransferMode), END_ELEMENT] */
			if (iso1SupportedEnergyTransferModeType_EnergyTransferMode_currArrayIndex < iso1SupportedEnergyTransferModeType->EnergyTransferMode.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 3, iso1SupportedEnergyTransferModeType->EnergyTransferMode.array[iso1SupportedEnergyTransferModeType_EnergyTransferMode_currArrayIndex++]);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,ChargingStatusReqType',  base type name='BodyBaseType',  content type='EMPTY',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  derivedBy='EXTENSION'.  */
static int encode_iso1ChargingStatusReqType(bitstream_t* stream, struct iso1ChargingStatusReqType* iso1ChargingStatusReqType) {
	int grammarID = 34;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 34:
			/* FirstStartTag[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2013:MsgBody,PaymentServiceSelectionResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2013:MsgBody":ResponseCode)',  derivedBy='EXTENSION'.  */
static int encode_iso1PaymentServiceSelectionResType(bitstream_t* stream, struct iso1PaymentServiceSelectionResType* iso1PaymentServiceSelectionResType) {
	int grammarID = 122;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 122:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, iso1PaymentServiceSelectionResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,DigestMethodType',  base type name='anyType',  content type='MIXED',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='((WC[##other:"http://www.w3.org/2000/09/xmldsig#"]){0-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_iso1DigestMethodType(bitstream_t* stream, struct iso1DigestMethodType* iso1DigestMethodType) {
	int grammarID = 312;
	int done = 0;
	int wcDone = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 312:
			/* FirstStartTag[ATTRIBUTE[STRING](Algorithm)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1DigestMethodType->Algorithm.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1DigestMethodType->Algorithm.characters, iso1DigestMethodType->Algorithm.charactersLen);
					}
				}
				grammarID = 115;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 115:
			/* StartTag[START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 116;
			} else 			if ( iso1DigestMethodType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else 			if ( iso1DigestMethodType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1DigestMethodType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1DigestMethodType->ANY.characters, iso1DigestMethodType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 116;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 116:
			/* Element[START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 116;
			} else 			if ( iso1DigestMethodType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else 			if ( iso1DigestMethodType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1DigestMethodType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1DigestMethodType->ANY.characters, iso1DigestMethodType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 116;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,SignaturePropertyType',  base type name='anyType',  content type='MIXED',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='((WC[##other:"http://www.w3.org/2000/09/xmldsig#"])){1-UNBOUNDED}',  derivedBy='RESTRICTION'.  */
static int encode_iso1SignaturePropertyType(bitstream_t* stream, struct iso1SignaturePropertyType* iso1SignaturePropertyType) {
	int grammarID = 363;
	int done = 0;
	int wcDone = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 363:
			/* FirstStartTag[ATTRIBUTE[STRING](Id), ATTRIBUTE[STRING](Target)] */
			if ( iso1SignaturePropertyType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SignaturePropertyType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1SignaturePropertyType->Id.characters, iso1SignaturePropertyType->Id.charactersLen);
					}
				}
				grammarID = 364;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SignaturePropertyType->Target.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1SignaturePropertyType->Target.characters, iso1SignaturePropertyType->Target.charactersLen);
					}
				}
				grammarID = 365;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 364:
			/* StartTag[ATTRIBUTE[STRING](Target)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SignaturePropertyType->Target.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1SignaturePropertyType->Target.characters, iso1SignaturePropertyType->Target.charactersLen);
					}
				}
				grammarID = 365;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 365:
			/* StartTag[START_ELEMENT_GENERIC, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 116;
			} else 			if ( iso1SignaturePropertyType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SignaturePropertyType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1SignaturePropertyType->ANY.characters, iso1SignaturePropertyType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 366;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 116:
			/* Element[START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 116;
			} else 			if ( iso1SignaturePropertyType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else 			if ( iso1SignaturePropertyType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SignaturePropertyType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1SignaturePropertyType->ANY.characters, iso1SignaturePropertyType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 116;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 366:
			/* Element[START_ELEMENT_GENERIC, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 116;
			} else 			if ( iso1SignaturePropertyType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1SignaturePropertyType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, iso1SignaturePropertyType->ANY.characters, iso1SignaturePropertyType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 366;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,PGPDataType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='(("http://www.w3.org/2000/09/xmldsig#":PGPKeyID,"http://www.w3.org/2000/09/xmldsig#":PGPKeyPacket{0-1},(WC[##other:"http://www.w3.org/2000/09/xmldsig#"]){0-UNBOUNDED})|("http://www.w3.org/2000/09/xmldsig#":PGPKeyPacket,(WC[##other:"http://www.w3.org/2000/09/xmldsig#"]){0-UNBOUNDED}))',  derivedBy='RESTRICTION'.  */
static int encode_iso1PGPDataType(bitstream_t* stream, struct iso1PGPDataType* iso1PGPDataType) {
	int grammarID = 367;
	int done = 0;
	int wcDone = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 367:
			/* FirstStartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPKeyID), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPKeyPacket)] */
			if ( iso1PGPDataType->PGPKeyID_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1PGPDataType->PGPKeyID.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1PGPDataType->PGPKeyID.bytes, iso1PGPDataType->PGPKeyID.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 368;
			} else 			if ( iso1PGPDataType->PGPKeyPacket_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1PGPDataType->PGPKeyPacket.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1PGPDataType->PGPKeyPacket.bytes, iso1PGPDataType->PGPKeyPacket.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 369;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 368:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPKeyPacket), START_ELEMENT_GENERIC, END_ELEMENT] */
			if ( iso1PGPDataType->PGPKeyPacket_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(iso1PGPDataType->PGPKeyPacket.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, iso1PGPDataType->PGPKeyPacket.bytes, iso1PGPDataType->PGPKeyPacket.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 369;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 369;
			} else 			if ( iso1PGPDataType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 369:
			/* Element[START_ELEMENT_GENERIC, END_ELEMENT] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 369;
			} else 			if ( iso1PGPDataType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

int encode_iso1EXISchemaInformedElementFragmentGrammar(bitstream_t* stream, struct iso1EXISchemaInformedElementFragmentGrammar* exiElementFrag) {
	int grammarID = 370;
	int done = 0;
	
	while(!done) {
		switch(grammarID) {
		case 370:
			/* First(xsi:type)(xsi:nil)StartTag[ATTRIBUTE[STRING](Algorithm), ATTRIBUTE[STRING](Encoding), ATTRIBUTE[STRING](Id), ATTRIBUTE[STRING]({urn:iso:15118:2:2013:MsgBody}Id), ATTRIBUTE[STRING]({urn:iso:15118:2:2013:MsgDataTypes}Id), ATTRIBUTE[STRING](MimeType), ATTRIBUTE[STRING]({urn:iso:15118:2:2013:MsgDataTypes}Name), ATTRIBUTE[STRING](Target), ATTRIBUTE[STRING](Type), ATTRIBUTE[STRING](URI), ATTRIBUTE_GENERIC, START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AuthorizationReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AuthorizationRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDef}Body), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}BodyElement), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}BulkChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}BulkChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}BulkSOC), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CableCheckReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CableCheckRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}CanonicalizationMethod), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Certificate), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateInstallationReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateInstallationRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateUpdateReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateUpdateRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeParameterDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeParameterDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeProgress), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeService), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingProfile), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingProfileEntryMaxNumberOfPhasesInUse), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingProfileEntryMaxPower), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingProfileEntryStart), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingSession), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingStatusReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingStatusRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ConsumptionCost), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ContractSignatureCertChain), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ContractSignatureEncryptedPrivateKey), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Cost), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CurrentDemandReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CurrentDemandRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVPowerDeliveryParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DC_EVStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DHpublickey), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DSAKeyValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DepartureTime), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EAmount), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EPriceLevel), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVCCID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVEnergyCapacity), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVEnergyRequest), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVErrorCode), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaxCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaxVoltage), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMinCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVPowerDeliveryParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVRESSSOC), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVReady), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSECurrentLimitAchieved), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSECurrentRegulationTolerance), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEEnergyToBeDelivered), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEIsolationStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaxCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaxCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMinimumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMinimumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSENominalVoltage), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSENotification), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEPeakCurrentRipple), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEPowerLimitAchieved), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEPresentCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEPresentVoltage), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEProcessing), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEStatusCode), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSETimeStamp), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEVoltageLimitAchieved), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVTargetCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVTargetVoltage), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EnergyTransferMode), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Entry), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Exponent), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FaultCode), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FaultMsg), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FreeService), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FullSOC), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}G), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}GenChallenge), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}HMACOutputLength), START_ELEMENT({urn:iso:15118:2:2013:MsgDef}Header), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}J), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyInfo), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyValue), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ListOfRootCertificateIDs), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Manifest), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MaxEntriesSAScheduleTuple), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}MeterID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeterInfo), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeteringReceiptReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeteringReceiptRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}MgmtData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Modulus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Multiplier), START_ELEMENT({urn:iso:15118:2:2013:MsgHeader}Notification), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}NotificationMaxDelay), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}NumEPriceLevels), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}OEMProvisioningCert), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Object), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}P), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPKeyID), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPKeyPacket), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMax), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMaxSchedule), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMaxScheduleEntry), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ParameterSet), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ParameterSetID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentDetailsReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentDetailsRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PaymentOption), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentOptionList), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentServiceSelectionReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentServiceSelectionRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PgenCounter), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PowerDeliveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PowerDeliveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PreChargeReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PreChargeRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Q), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RCD), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RSAKeyValue), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ReceiptRequired), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RelativeTimeInterval), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RemainingTimeToBulkSoC), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RemainingTimeToFullSoC), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RequestedEnergyTransferMode), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RetrievalMethod), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RetryCounter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RootCertificateID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SAProvisioningCertificateChain), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleList), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleTuple), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SAScheduleTupleID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleTupleID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SASchedules), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKIData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKISexp), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariff), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffDescription), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffEntry), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffID), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Seed), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SelectedPaymentOption), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SelectedServiceList), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Service), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceCategory), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceCategory), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDetailReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDetailRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceList), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceName), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceParameterList), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceScope), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceScope), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionID), START_ELEMENT({urn:iso:15118:2:2013:MsgHeader}SessionID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionSetupReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionSetupRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionStopReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionStopRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SigMeterReading), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Signature), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperties), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperty), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignedInfo), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SubCertificates), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SupportedEnergyTransferMode), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}TMeter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}TimeInterval), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transform), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Unit), START_ELEMENT({urn:iso:15118:2:2013:MsgDef}V2G_Message), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Value), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}WeldingDetectionReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}WeldingDetectionRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509CRL), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Certificate), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Data), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509IssuerName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509IssuerSerial), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SKI), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SerialNumber), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SubjectName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}XPath), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Y), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}amount), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}amountMultiplier), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}boolValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}byteValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}costKind), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}duration), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}eMAID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}intValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}physicalValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}shortValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}start), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}startValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}stringValue), START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if ( exiElementFrag->Id_isUsed == 1u ) {
				exiElementFrag->Id_isUsed = 0u; /* hack to indicate for next loop that this has been handled already */
				errn = encodeNBitUnsignedInteger(stream, 9, 4);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiElementFrag->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiElementFrag->Id.characters, exiElementFrag->Id.charactersLen);
					}
				}
				grammarID = 370;
			} else 			if (1==0) {
				errn = encodeNBitUnsignedInteger(stream, 9, 255);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else 			if ( exiElementFrag->CHARACTERS_GENERIC_isUsed == 1u ) {
				exiElementFrag->CHARACTERS_GENERIC_isUsed = 0u; /* hack to indicate for next loop that this has been handled already */
				errn = encodeNBitUnsignedInteger(stream, 9, 256);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiElementFrag->CHARACTERS_GENERIC.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiElementFrag->CHARACTERS_GENERIC.characters, exiElementFrag->CHARACTERS_GENERIC.charactersLen);
					}
				}
				grammarID = 371;
			} else {
				errn = encodeNBitUnsignedInteger(stream, 9, 255); /* EE */
				done = 1;
			}
			break;
		case 371:
			/* Element[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AuthorizationReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AuthorizationRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDef}Body), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}BodyElement), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}BulkChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}BulkChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}BulkSOC), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CableCheckReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CableCheckRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}CanonicalizationMethod), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Certificate), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateInstallationReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateInstallationRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateUpdateReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateUpdateRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeParameterDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeParameterDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeProgress), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeService), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingProfile), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingProfileEntryMaxNumberOfPhasesInUse), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingProfileEntryMaxPower), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingProfileEntryStart), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingSession), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingStatusReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingStatusRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ConsumptionCost), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ContractSignatureCertChain), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ContractSignatureEncryptedPrivateKey), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Cost), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CurrentDemandReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CurrentDemandRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVPowerDeliveryParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DC_EVStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DHpublickey), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DSAKeyValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DepartureTime), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EAmount), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EPriceLevel), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVCCID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVEnergyCapacity), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVEnergyRequest), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVErrorCode), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaxCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaxVoltage), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMinCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVPowerDeliveryParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVRESSSOC), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVReady), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSECurrentLimitAchieved), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSECurrentRegulationTolerance), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEEnergyToBeDelivered), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEIsolationStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaxCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaxCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMinimumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMinimumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSENominalVoltage), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSENotification), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEPeakCurrentRipple), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEPowerLimitAchieved), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEPresentCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEPresentVoltage), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEProcessing), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEStatusCode), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSETimeStamp), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEVoltageLimitAchieved), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVTargetCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVTargetVoltage), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EnergyTransferMode), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Entry), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Exponent), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FaultCode), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FaultMsg), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FreeService), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FullSOC), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}G), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}GenChallenge), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}HMACOutputLength), START_ELEMENT({urn:iso:15118:2:2013:MsgDef}Header), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}J), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyInfo), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyValue), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ListOfRootCertificateIDs), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Manifest), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MaxEntriesSAScheduleTuple), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}MeterID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeterInfo), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeteringReceiptReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeteringReceiptRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}MgmtData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Modulus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Multiplier), START_ELEMENT({urn:iso:15118:2:2013:MsgHeader}Notification), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}NotificationMaxDelay), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}NumEPriceLevels), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}OEMProvisioningCert), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Object), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}P), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPKeyID), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPKeyPacket), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMax), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMaxSchedule), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMaxScheduleEntry), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ParameterSet), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ParameterSetID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentDetailsReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentDetailsRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PaymentOption), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentOptionList), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentServiceSelectionReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentServiceSelectionRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PgenCounter), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PowerDeliveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PowerDeliveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PreChargeReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PreChargeRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Q), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RCD), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RSAKeyValue), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ReceiptRequired), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RelativeTimeInterval), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RemainingTimeToBulkSoC), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RemainingTimeToFullSoC), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RequestedEnergyTransferMode), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RetrievalMethod), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RetryCounter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RootCertificateID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SAProvisioningCertificateChain), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleList), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleTuple), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SAScheduleTupleID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleTupleID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SASchedules), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKIData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKISexp), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariff), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffDescription), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffEntry), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffID), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Seed), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SelectedPaymentOption), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SelectedServiceList), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Service), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceCategory), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceCategory), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDetailReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDetailRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceList), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceName), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceParameterList), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceScope), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceScope), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionID), START_ELEMENT({urn:iso:15118:2:2013:MsgHeader}SessionID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionSetupReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionSetupRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionStopReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionStopRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SigMeterReading), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Signature), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperties), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperty), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignedInfo), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SubCertificates), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SupportedEnergyTransferMode), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}TMeter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}TimeInterval), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transform), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Unit), START_ELEMENT({urn:iso:15118:2:2013:MsgDef}V2G_Message), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Value), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}WeldingDetectionReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}WeldingDetectionRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509CRL), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Certificate), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Data), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509IssuerName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509IssuerSerial), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SKI), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SerialNumber), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SubjectName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}XPath), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Y), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}amount), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}amountMultiplier), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}boolValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}byteValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}costKind), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}duration), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}eMAID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}intValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}physicalValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}shortValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}start), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}startValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}stringValue), START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = encodeNBitUnsignedInteger(stream, 8, 244);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 4;
			} else 			if ( exiElementFrag->CHARACTERS_GENERIC_isUsed == 1u ) {
				exiElementFrag->CHARACTERS_GENERIC_isUsed = 0u; /* hack to indicate for next loop that this has been handled already */
				errn = encodeNBitUnsignedInteger(stream, 8, 245);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiElementFrag->CHARACTERS_GENERIC.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiElementFrag->CHARACTERS_GENERIC.characters, exiElementFrag->CHARACTERS_GENERIC.charactersLen);
					}
				}
				grammarID = 371;
			} else {
				errn = encodeNBitUnsignedInteger(stream, 8, 244); /* EE */
				done = 1;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}



int encode_iso1ExiDocument(bitstream_t* stream, struct iso1EXIDocument* exiDoc) {
	errn = writeEXIHeader(stream);

	if(errn == 0) {
		/* DocContent[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AuthorizationReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AuthorizationRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}BodyElement), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CableCheckReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CableCheckRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}CanonicalizationMethod), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateInstallationReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateInstallationRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateUpdateReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateUpdateRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeParameterDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeParameterDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingStatusReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingStatusRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CurrentDemandReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CurrentDemandRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVPowerDeliveryParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVStatus), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DSAKeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVPowerDeliveryParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Entry), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyInfo), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Manifest), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeteringReceiptReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeteringReceiptRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}MgmtData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Object), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPData), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMaxScheduleEntry), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentDetailsReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentDetailsRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentServiceSelectionReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentServiceSelectionRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PowerDeliveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PowerDeliveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PreChargeReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PreChargeRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RSAKeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RelativeTimeInterval), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RetrievalMethod), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleList), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SASchedules), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKIData), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffEntry), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDetailReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDetailRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionSetupReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionSetupRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionStopReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionStopRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Signature), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperties), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperty), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignedInfo), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}TimeInterval), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transform), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), START_ELEMENT({urn:iso:15118:2:2013:MsgDef}V2G_Message), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}WeldingDetectionReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}WeldingDetectionRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Data), START_ELEMENT_GENERIC] */
		if ( exiDoc->AC_EVChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 7, 0);
			if(errn == 0) {
				errn = encode_iso1AC_EVChargeParameterType(stream, &exiDoc->AC_EVChargeParameter );
			}
		} else if ( exiDoc->AC_EVSEChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 7, 1);
			if(errn == 0) {
				errn = encode_iso1AC_EVSEChargeParameterType(stream, &exiDoc->AC_EVSEChargeParameter );
			}
		} else if ( exiDoc->AC_EVSEStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEStatus) */
			errn = encodeNBitUnsignedInteger(stream, 7, 2);
			if(errn == 0) {
				errn = encode_iso1AC_EVSEStatusType(stream, &exiDoc->AC_EVSEStatus );
			}
		} else if ( exiDoc->AuthorizationReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AuthorizationReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 3);
			if(errn == 0) {
				errn = encode_iso1AuthorizationReqType(stream, &exiDoc->AuthorizationReq );
			}
		} else if ( exiDoc->AuthorizationRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AuthorizationRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 4);
			if(errn == 0) {
				errn = encode_iso1AuthorizationResType(stream, &exiDoc->AuthorizationRes );
			}
		} else if ( exiDoc->BodyElement_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}BodyElement) */
			errn = encodeNBitUnsignedInteger(stream, 7, 5);
			if(errn == 0) {
				errn = encode_iso1BodyBaseType(stream, &exiDoc->BodyElement );
			}
		} else if ( exiDoc->CableCheckReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CableCheckReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 6);
			if(errn == 0) {
				errn = encode_iso1CableCheckReqType(stream, &exiDoc->CableCheckReq );
			}
		} else if ( exiDoc->CableCheckRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CableCheckRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 7);
			if(errn == 0) {
				errn = encode_iso1CableCheckResType(stream, &exiDoc->CableCheckRes );
			}
		} else if ( exiDoc->CanonicalizationMethod_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}CanonicalizationMethod) */
			errn = encodeNBitUnsignedInteger(stream, 7, 8);
			if(errn == 0) {
				errn = encode_iso1CanonicalizationMethodType(stream, &exiDoc->CanonicalizationMethod );
			}
		} else if ( exiDoc->CertificateInstallationReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateInstallationReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 9);
			if(errn == 0) {
				errn = encode_iso1CertificateInstallationReqType(stream, &exiDoc->CertificateInstallationReq );
			}
		} else if ( exiDoc->CertificateInstallationRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateInstallationRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 10);
			if(errn == 0) {
				errn = encode_iso1CertificateInstallationResType(stream, &exiDoc->CertificateInstallationRes );
			}
		} else if ( exiDoc->CertificateUpdateReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateUpdateReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 11);
			if(errn == 0) {
				errn = encode_iso1CertificateUpdateReqType(stream, &exiDoc->CertificateUpdateReq );
			}
		} else if ( exiDoc->CertificateUpdateRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateUpdateRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 12);
			if(errn == 0) {
				errn = encode_iso1CertificateUpdateResType(stream, &exiDoc->CertificateUpdateRes );
			}
		} else if ( exiDoc->ChargeParameterDiscoveryReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeParameterDiscoveryReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 13);
			if(errn == 0) {
				errn = encode_iso1ChargeParameterDiscoveryReqType(stream, &exiDoc->ChargeParameterDiscoveryReq );
			}
		} else if ( exiDoc->ChargeParameterDiscoveryRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeParameterDiscoveryRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 14);
			if(errn == 0) {
				errn = encode_iso1ChargeParameterDiscoveryResType(stream, &exiDoc->ChargeParameterDiscoveryRes );
			}
		} else if ( exiDoc->ChargingStatusReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingStatusReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 15);
			if(errn == 0) {
				errn = encode_iso1ChargingStatusReqType(stream, &exiDoc->ChargingStatusReq );
			}
		} else if ( exiDoc->ChargingStatusRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingStatusRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 16);
			if(errn == 0) {
				errn = encode_iso1ChargingStatusResType(stream, &exiDoc->ChargingStatusRes );
			}
		} else if ( exiDoc->CurrentDemandReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CurrentDemandReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 17);
			if(errn == 0) {
				errn = encode_iso1CurrentDemandReqType(stream, &exiDoc->CurrentDemandReq );
			}
		} else if ( exiDoc->CurrentDemandRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CurrentDemandRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 18);
			if(errn == 0) {
				errn = encode_iso1CurrentDemandResType(stream, &exiDoc->CurrentDemandRes );
			}
		} else if ( exiDoc->DC_EVChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 7, 19);
			if(errn == 0) {
				errn = encode_iso1DC_EVChargeParameterType(stream, &exiDoc->DC_EVChargeParameter );
			}
		} else if ( exiDoc->DC_EVPowerDeliveryParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVPowerDeliveryParameter) */
			errn = encodeNBitUnsignedInteger(stream, 7, 20);
			if(errn == 0) {
				errn = encode_iso1DC_EVPowerDeliveryParameterType(stream, &exiDoc->DC_EVPowerDeliveryParameter );
			}
		} else if ( exiDoc->DC_EVSEChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 7, 21);
			if(errn == 0) {
				errn = encode_iso1DC_EVSEChargeParameterType(stream, &exiDoc->DC_EVSEChargeParameter );
			}
		} else if ( exiDoc->DC_EVSEStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEStatus) */
			errn = encodeNBitUnsignedInteger(stream, 7, 22);
			if(errn == 0) {
				errn = encode_iso1DC_EVSEStatusType(stream, &exiDoc->DC_EVSEStatus );
			}
		} else if ( exiDoc->DC_EVStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVStatus) */
			errn = encodeNBitUnsignedInteger(stream, 7, 23);
			if(errn == 0) {
				errn = encode_iso1DC_EVStatusType(stream, &exiDoc->DC_EVStatus );
			}
		} else if ( exiDoc->DSAKeyValue_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DSAKeyValue) */
			errn = encodeNBitUnsignedInteger(stream, 7, 24);
			if(errn == 0) {
				errn = encode_iso1DSAKeyValueType(stream, &exiDoc->DSAKeyValue );
			}
		} else if ( exiDoc->DigestMethod_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod) */
			errn = encodeNBitUnsignedInteger(stream, 7, 25);
			if(errn == 0) {
				errn = encode_iso1DigestMethodType(stream, &exiDoc->DigestMethod );
			}
		} else if ( exiDoc->DigestValue_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestValue) */
			errn = encodeNBitUnsignedInteger(stream, 7, 26);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiDoc->DigestValue.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiDoc->DigestValue.bytes, exiDoc->DigestValue.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiDoc->EVChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 7, 27);
			if(errn == 0) {
				errn = encode_iso1EVChargeParameterType(stream, &exiDoc->EVChargeParameter );
			}
		} else if ( exiDoc->EVPowerDeliveryParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVPowerDeliveryParameter) */
			errn = encodeNBitUnsignedInteger(stream, 7, 28);
			if(errn == 0) {
				errn = encode_iso1EVPowerDeliveryParameterType(stream, &exiDoc->EVPowerDeliveryParameter );
			}
		} else if ( exiDoc->EVSEChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 7, 29);
			if(errn == 0) {
				errn = encode_iso1EVSEChargeParameterType(stream, &exiDoc->EVSEChargeParameter );
			}
		} else if ( exiDoc->EVSEStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEStatus) */
			errn = encodeNBitUnsignedInteger(stream, 7, 30);
			if(errn == 0) {
				errn = encode_iso1EVSEStatusType(stream, &exiDoc->EVSEStatus );
			}
		} else if ( exiDoc->EVStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVStatus) */
			errn = encodeNBitUnsignedInteger(stream, 7, 31);
			if(errn == 0) {
				errn = encode_iso1EVStatusType(stream, &exiDoc->EVStatus );
			}
		} else if ( exiDoc->Entry_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Entry) */
			errn = encodeNBitUnsignedInteger(stream, 7, 32);
			if(errn == 0) {
				errn = encode_iso1EntryType(stream, &exiDoc->Entry );
			}
		} else if ( exiDoc->KeyInfo_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyInfo) */
			errn = encodeNBitUnsignedInteger(stream, 7, 33);
			if(errn == 0) {
				errn = encode_iso1KeyInfoType(stream, &exiDoc->KeyInfo );
			}
		} else if ( exiDoc->KeyName_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyName) */
			errn = encodeNBitUnsignedInteger(stream, 7, 34);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiDoc->KeyName.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiDoc->KeyName.characters, exiDoc->KeyName.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiDoc->KeyValue_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyValue) */
			errn = encodeNBitUnsignedInteger(stream, 7, 35);
			if(errn == 0) {
				errn = encode_iso1KeyValueType(stream, &exiDoc->KeyValue );
			}
		} else if ( exiDoc->Manifest_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Manifest) */
			errn = encodeNBitUnsignedInteger(stream, 7, 36);
			if(errn == 0) {
				errn = encode_iso1ManifestType(stream, &exiDoc->Manifest );
			}
		} else if ( exiDoc->MeteringReceiptReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeteringReceiptReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 37);
			if(errn == 0) {
				errn = encode_iso1MeteringReceiptReqType(stream, &exiDoc->MeteringReceiptReq );
			}
		} else if ( exiDoc->MeteringReceiptRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeteringReceiptRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 38);
			if(errn == 0) {
				errn = encode_iso1MeteringReceiptResType(stream, &exiDoc->MeteringReceiptRes );
			}
		} else if ( exiDoc->MgmtData_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}MgmtData) */
			errn = encodeNBitUnsignedInteger(stream, 7, 39);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiDoc->MgmtData.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiDoc->MgmtData.characters, exiDoc->MgmtData.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiDoc->Object_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Object) */
			errn = encodeNBitUnsignedInteger(stream, 7, 40);
			if(errn == 0) {
				errn = encode_iso1ObjectType(stream, &exiDoc->Object );
			}
		} else if ( exiDoc->PGPData_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPData) */
			errn = encodeNBitUnsignedInteger(stream, 7, 41);
			if(errn == 0) {
				errn = encode_iso1PGPDataType(stream, &exiDoc->PGPData );
			}
		} else if ( exiDoc->PMaxScheduleEntry_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMaxScheduleEntry) */
			errn = encodeNBitUnsignedInteger(stream, 7, 42);
			if(errn == 0) {
				errn = encode_iso1PMaxScheduleEntryType(stream, &exiDoc->PMaxScheduleEntry );
			}
		} else if ( exiDoc->PaymentDetailsReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentDetailsReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 43);
			if(errn == 0) {
				errn = encode_iso1PaymentDetailsReqType(stream, &exiDoc->PaymentDetailsReq );
			}
		} else if ( exiDoc->PaymentDetailsRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentDetailsRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 44);
			if(errn == 0) {
				errn = encode_iso1PaymentDetailsResType(stream, &exiDoc->PaymentDetailsRes );
			}
		} else if ( exiDoc->PaymentServiceSelectionReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentServiceSelectionReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 45);
			if(errn == 0) {
				errn = encode_iso1PaymentServiceSelectionReqType(stream, &exiDoc->PaymentServiceSelectionReq );
			}
		} else if ( exiDoc->PaymentServiceSelectionRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentServiceSelectionRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 46);
			if(errn == 0) {
				errn = encode_iso1PaymentServiceSelectionResType(stream, &exiDoc->PaymentServiceSelectionRes );
			}
		} else if ( exiDoc->PowerDeliveryReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PowerDeliveryReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 47);
			if(errn == 0) {
				errn = encode_iso1PowerDeliveryReqType(stream, &exiDoc->PowerDeliveryReq );
			}
		} else if ( exiDoc->PowerDeliveryRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PowerDeliveryRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 48);
			if(errn == 0) {
				errn = encode_iso1PowerDeliveryResType(stream, &exiDoc->PowerDeliveryRes );
			}
		} else if ( exiDoc->PreChargeReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PreChargeReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 49);
			if(errn == 0) {
				errn = encode_iso1PreChargeReqType(stream, &exiDoc->PreChargeReq );
			}
		} else if ( exiDoc->PreChargeRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PreChargeRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 50);
			if(errn == 0) {
				errn = encode_iso1PreChargeResType(stream, &exiDoc->PreChargeRes );
			}
		} else if ( exiDoc->RSAKeyValue_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RSAKeyValue) */
			errn = encodeNBitUnsignedInteger(stream, 7, 51);
			if(errn == 0) {
				errn = encode_iso1RSAKeyValueType(stream, &exiDoc->RSAKeyValue );
			}
		} else if ( exiDoc->Reference_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference) */
			errn = encodeNBitUnsignedInteger(stream, 7, 52);
			if(errn == 0) {
				errn = encode_iso1ReferenceType(stream, &exiDoc->Reference );
			}
		} else if ( exiDoc->RelativeTimeInterval_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RelativeTimeInterval) */
			errn = encodeNBitUnsignedInteger(stream, 7, 53);
			if(errn == 0) {
				errn = encode_iso1RelativeTimeIntervalType(stream, &exiDoc->RelativeTimeInterval );
			}
		} else if ( exiDoc->RetrievalMethod_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RetrievalMethod) */
			errn = encodeNBitUnsignedInteger(stream, 7, 54);
			if(errn == 0) {
				errn = encode_iso1RetrievalMethodType(stream, &exiDoc->RetrievalMethod );
			}
		} else if ( exiDoc->SAScheduleList_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleList) */
			errn = encodeNBitUnsignedInteger(stream, 7, 55);
			if(errn == 0) {
				errn = encode_iso1SAScheduleListType(stream, &exiDoc->SAScheduleList );
			}
		} else if ( exiDoc->SASchedules_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SASchedules) */
			errn = encodeNBitUnsignedInteger(stream, 7, 56);
			if(errn == 0) {
				errn = encode_iso1SASchedulesType(stream, &exiDoc->SASchedules );
			}
		} else if ( exiDoc->SPKIData_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKIData) */
			errn = encodeNBitUnsignedInteger(stream, 7, 57);
			if(errn == 0) {
				errn = encode_iso1SPKIDataType(stream, &exiDoc->SPKIData );
			}
		} else if ( exiDoc->SalesTariffEntry_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffEntry) */
			errn = encodeNBitUnsignedInteger(stream, 7, 58);
			if(errn == 0) {
				errn = encode_iso1SalesTariffEntryType(stream, &exiDoc->SalesTariffEntry );
			}
		} else if ( exiDoc->ServiceDetailReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDetailReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 59);
			if(errn == 0) {
				errn = encode_iso1ServiceDetailReqType(stream, &exiDoc->ServiceDetailReq );
			}
		} else if ( exiDoc->ServiceDetailRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDetailRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 60);
			if(errn == 0) {
				errn = encode_iso1ServiceDetailResType(stream, &exiDoc->ServiceDetailRes );
			}
		} else if ( exiDoc->ServiceDiscoveryReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDiscoveryReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 61);
			if(errn == 0) {
				errn = encode_iso1ServiceDiscoveryReqType(stream, &exiDoc->ServiceDiscoveryReq );
			}
		} else if ( exiDoc->ServiceDiscoveryRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDiscoveryRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 62);
			if(errn == 0) {
				errn = encode_iso1ServiceDiscoveryResType(stream, &exiDoc->ServiceDiscoveryRes );
			}
		} else if ( exiDoc->SessionSetupReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionSetupReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 63);
			if(errn == 0) {
				errn = encode_iso1SessionSetupReqType(stream, &exiDoc->SessionSetupReq );
			}
		} else if ( exiDoc->SessionSetupRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionSetupRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 64);
			if(errn == 0) {
				errn = encode_iso1SessionSetupResType(stream, &exiDoc->SessionSetupRes );
			}
		} else if ( exiDoc->SessionStopReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionStopReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 65);
			if(errn == 0) {
				errn = encode_iso1SessionStopReqType(stream, &exiDoc->SessionStopReq );
			}
		} else if ( exiDoc->SessionStopRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionStopRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 66);
			if(errn == 0) {
				errn = encode_iso1SessionStopResType(stream, &exiDoc->SessionStopRes );
			}
		} else if ( exiDoc->Signature_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Signature) */
			errn = encodeNBitUnsignedInteger(stream, 7, 67);
			if(errn == 0) {
				errn = encode_iso1SignatureType(stream, &exiDoc->Signature );
			}
		} else if ( exiDoc->SignatureMethod_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureMethod) */
			errn = encodeNBitUnsignedInteger(stream, 7, 68);
			if(errn == 0) {
				errn = encode_iso1SignatureMethodType(stream, &exiDoc->SignatureMethod );
			}
		} else if ( exiDoc->SignatureProperties_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperties) */
			errn = encodeNBitUnsignedInteger(stream, 7, 69);
			if(errn == 0) {
				errn = encode_iso1SignaturePropertiesType(stream, &exiDoc->SignatureProperties );
			}
		} else if ( exiDoc->SignatureProperty_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperty) */
			errn = encodeNBitUnsignedInteger(stream, 7, 70);
			if(errn == 0) {
				errn = encode_iso1SignaturePropertyType(stream, &exiDoc->SignatureProperty );
			}
		} else if ( exiDoc->SignatureValue_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureValue) */
			errn = encodeNBitUnsignedInteger(stream, 7, 71);
			if(errn == 0) {
				errn = encode_iso1SignatureValueType(stream, &exiDoc->SignatureValue );
			}
		} else if ( exiDoc->SignedInfo_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignedInfo) */
			errn = encodeNBitUnsignedInteger(stream, 7, 72);
			if(errn == 0) {
				errn = encode_iso1SignedInfoType(stream, &exiDoc->SignedInfo );
			}
		} else if ( exiDoc->TimeInterval_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}TimeInterval) */
			errn = encodeNBitUnsignedInteger(stream, 7, 73);
			if(errn == 0) {
				errn = encode_iso1IntervalType(stream, &exiDoc->TimeInterval );
			}
		} else if ( exiDoc->Transform_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transform) */
			errn = encodeNBitUnsignedInteger(stream, 7, 74);
			if(errn == 0) {
				errn = encode_iso1TransformType(stream, &exiDoc->Transform );
			}
		} else if ( exiDoc->Transforms_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms) */
			errn = encodeNBitUnsignedInteger(stream, 7, 75);
			if(errn == 0) {
				errn = encode_iso1TransformsType(stream, &exiDoc->Transforms );
			}
		} else if ( exiDoc->V2G_Message_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDef}V2G_Message) */
			errn = encodeNBitUnsignedInteger(stream, 7, 76);
			if(errn == 0) {
				errn = encode_iso1AnonType_V2G_Message(stream, &exiDoc->V2G_Message );
			}
		} else if ( exiDoc->WeldingDetectionReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}WeldingDetectionReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 77);
			if(errn == 0) {
				errn = encode_iso1WeldingDetectionReqType(stream, &exiDoc->WeldingDetectionReq );
			}
		} else if ( exiDoc->WeldingDetectionRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}WeldingDetectionRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 78);
			if(errn == 0) {
				errn = encode_iso1WeldingDetectionResType(stream, &exiDoc->WeldingDetectionRes );
			}
		} else if ( exiDoc->X509Data_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Data) */
			errn = encodeNBitUnsignedInteger(stream, 7, 79);
			if(errn == 0) {
				errn = encode_iso1X509DataType(stream, &exiDoc->X509Data );
			}
		} else {
			errn = EXI_ERROR_UNKOWN_EVENT;
		}

	}

	if(errn == 0) {
		/* flush any pending bits */
		errn = encodeFinish(stream);
	}

	return errn;
}

#if DEPLOY_ISO1_CODEC_FRAGMENT == SUPPORT_YES
int encode_iso1ExiFragment(bitstream_t* stream, struct iso1EXIFragment* exiFrag) {
	errn = writeEXIHeader(stream);

	if(errn == 0) {
		/* FragmentContent[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AuthorizationReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AuthorizationRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDef}Body), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}BodyElement), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}BulkChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}BulkChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}BulkSOC), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CableCheckReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CableCheckRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}CanonicalizationMethod), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Certificate), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateInstallationReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateInstallationRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateUpdateReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateUpdateRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeParameterDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeParameterDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeProgress), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeService), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingProfile), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingProfileEntryMaxNumberOfPhasesInUse), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingProfileEntryMaxPower), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingProfileEntryStart), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingSession), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingStatusReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingStatusRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ConsumptionCost), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ContractSignatureCertChain), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ContractSignatureEncryptedPrivateKey), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Cost), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CurrentDemandReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CurrentDemandRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVPowerDeliveryParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DC_EVStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DHpublickey), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DSAKeyValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DepartureTime), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EAmount), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EPriceLevel), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVCCID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVEnergyCapacity), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVEnergyRequest), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVErrorCode), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaxCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaxVoltage), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMinCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVPowerDeliveryParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVRESSSOC), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVReady), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSECurrentLimitAchieved), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSECurrentRegulationTolerance), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEEnergyToBeDelivered), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEIsolationStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaxCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaxCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMinimumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMinimumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSENominalVoltage), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSENotification), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEPeakCurrentRipple), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEPowerLimitAchieved), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEPresentCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEPresentVoltage), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEProcessing), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEStatusCode), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSETimeStamp), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEVoltageLimitAchieved), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVTargetCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVTargetVoltage), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EnergyTransferMode), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Entry), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Exponent), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FaultCode), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FaultMsg), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FreeService), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FullSOC), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}G), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}GenChallenge), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}HMACOutputLength), START_ELEMENT({urn:iso:15118:2:2013:MsgDef}Header), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}J), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyInfo), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyValue), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ListOfRootCertificateIDs), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Manifest), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MaxEntriesSAScheduleTuple), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}MeterID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeterInfo), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeteringReceiptReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeteringReceiptRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}MgmtData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Modulus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Multiplier), START_ELEMENT({urn:iso:15118:2:2013:MsgHeader}Notification), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}NotificationMaxDelay), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}NumEPriceLevels), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}OEMProvisioningCert), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Object), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}P), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPKeyID), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPKeyPacket), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMax), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMaxSchedule), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMaxScheduleEntry), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ParameterSet), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ParameterSetID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentDetailsReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentDetailsRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PaymentOption), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentOptionList), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentServiceSelectionReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentServiceSelectionRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PgenCounter), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PowerDeliveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PowerDeliveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PreChargeReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PreChargeRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Q), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RCD), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RSAKeyValue), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ReceiptRequired), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RelativeTimeInterval), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RemainingTimeToBulkSoC), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RemainingTimeToFullSoC), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RequestedEnergyTransferMode), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RetrievalMethod), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RetryCounter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RootCertificateID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SAProvisioningCertificateChain), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleList), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleTuple), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SAScheduleTupleID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleTupleID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SASchedules), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKIData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKISexp), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariff), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffDescription), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffEntry), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffID), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Seed), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SelectedPaymentOption), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SelectedServiceList), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Service), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceCategory), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceCategory), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDetailReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDetailRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceList), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceName), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceParameterList), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceScope), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceScope), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionID), START_ELEMENT({urn:iso:15118:2:2013:MsgHeader}SessionID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionSetupReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionSetupRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionStopReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionStopRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SigMeterReading), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Signature), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperties), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperty), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignedInfo), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SubCertificates), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SupportedEnergyTransferMode), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}TMeter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}TimeInterval), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transform), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Unit), START_ELEMENT({urn:iso:15118:2:2013:MsgDef}V2G_Message), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Value), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}WeldingDetectionReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}WeldingDetectionRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509CRL), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Certificate), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Data), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509IssuerName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509IssuerSerial), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SKI), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SerialNumber), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SubjectName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}XPath), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Y), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}amount), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}amountMultiplier), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}boolValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}byteValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}costKind), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}duration), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}eMAID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}intValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}physicalValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}shortValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}start), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}startValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}stringValue), START_ELEMENT_GENERIC, END_DOCUMENT] */
		if ( exiFrag->AC_EVChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 0);
			if(errn == 0) {
				errn = encode_iso1AC_EVChargeParameterType(stream, &exiFrag->AC_EVChargeParameter );
			}
		} else if ( exiFrag->AC_EVSEChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 1);
			if(errn == 0) {
				errn = encode_iso1AC_EVSEChargeParameterType(stream, &exiFrag->AC_EVSEChargeParameter );
			}
		} else if ( exiFrag->AC_EVSEStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AC_EVSEStatus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 2);
			if(errn == 0) {
				errn = encode_iso1AC_EVSEStatusType(stream, &exiFrag->AC_EVSEStatus );
			}
		} else if ( exiFrag->AC_EVSEStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEStatus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 3);
			if(errn == 0) {
				errn = encode_iso1AC_EVSEStatusType(stream, &exiFrag->AC_EVSEStatus );
			}
		} else if ( exiFrag->AuthorizationReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AuthorizationReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 4);
			if(errn == 0) {
				errn = encode_iso1AuthorizationReqType(stream, &exiFrag->AuthorizationReq );
			}
		} else if ( exiFrag->AuthorizationRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AuthorizationRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 5);
			if(errn == 0) {
				errn = encode_iso1AuthorizationResType(stream, &exiFrag->AuthorizationRes );
			}
		} else if ( exiFrag->Body_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDef}Body) */
			errn = encodeNBitUnsignedInteger(stream, 8, 6);
			if(errn == 0) {
				errn = encode_iso1BodyType(stream, &exiFrag->Body );
			}
		} else if ( exiFrag->BodyElement_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}BodyElement) */
			errn = encodeNBitUnsignedInteger(stream, 8, 7);
			if(errn == 0) {
				errn = encode_iso1BodyBaseType(stream, &exiFrag->BodyElement );
			}
		} else if ( exiFrag->BulkChargingComplete_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}BulkChargingComplete) */
			errn = encodeNBitUnsignedInteger(stream, 8, 8);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->BulkChargingComplete);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->BulkChargingComplete_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}BulkChargingComplete) */
			errn = encodeNBitUnsignedInteger(stream, 8, 9);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->BulkChargingComplete);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->BulkSOC_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}BulkSOC) */
			errn = encodeNBitUnsignedInteger(stream, 8, 10);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(exiFrag->BulkSOC - 0));
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->CableCheckReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CableCheckReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 11);
			if(errn == 0) {
				errn = encode_iso1CableCheckReqType(stream, &exiFrag->CableCheckReq );
			}
		} else if ( exiFrag->CableCheckRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CableCheckRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 12);
			if(errn == 0) {
				errn = encode_iso1CableCheckResType(stream, &exiFrag->CableCheckRes );
			}
		} else if ( exiFrag->CanonicalizationMethod_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}CanonicalizationMethod) */
			errn = encodeNBitUnsignedInteger(stream, 8, 13);
			if(errn == 0) {
				errn = encode_iso1CanonicalizationMethodType(stream, &exiFrag->CanonicalizationMethod );
			}
		} else if ( exiFrag->Certificate_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Certificate) */
			errn = encodeNBitUnsignedInteger(stream, 8, 14);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->Certificate.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->Certificate.bytes, exiFrag->Certificate.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->CertificateInstallationReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateInstallationReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 15);
			if(errn == 0) {
				errn = encode_iso1CertificateInstallationReqType(stream, &exiFrag->CertificateInstallationReq );
			}
		} else if ( exiFrag->CertificateInstallationRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateInstallationRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 16);
			if(errn == 0) {
				errn = encode_iso1CertificateInstallationResType(stream, &exiFrag->CertificateInstallationRes );
			}
		} else if ( exiFrag->CertificateUpdateReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateUpdateReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 17);
			if(errn == 0) {
				errn = encode_iso1CertificateUpdateReqType(stream, &exiFrag->CertificateUpdateReq );
			}
		} else if ( exiFrag->CertificateUpdateRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateUpdateRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 18);
			if(errn == 0) {
				errn = encode_iso1CertificateUpdateResType(stream, &exiFrag->CertificateUpdateRes );
			}
		} else if ( exiFrag->ChargeParameterDiscoveryReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeParameterDiscoveryReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 19);
			if(errn == 0) {
				errn = encode_iso1ChargeParameterDiscoveryReqType(stream, &exiFrag->ChargeParameterDiscoveryReq );
			}
		} else if ( exiFrag->ChargeParameterDiscoveryRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeParameterDiscoveryRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 20);
			if(errn == 0) {
				errn = encode_iso1ChargeParameterDiscoveryResType(stream, &exiFrag->ChargeParameterDiscoveryRes );
			}
		} else if ( exiFrag->ChargeProgress_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeProgress) */
			errn = encodeNBitUnsignedInteger(stream, 8, 21);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 2, exiFrag->ChargeProgress);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ChargeService_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeService) */
			errn = encodeNBitUnsignedInteger(stream, 8, 22);
			if(errn == 0) {
				errn = encode_iso1ChargeServiceType(stream, &exiFrag->ChargeService );
			}
		} else if ( exiFrag->ChargingComplete_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingComplete) */
			errn = encodeNBitUnsignedInteger(stream, 8, 23);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->ChargingComplete);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ChargingComplete_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingComplete) */
			errn = encodeNBitUnsignedInteger(stream, 8, 24);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->ChargingComplete);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ChargingProfile_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingProfile) */
			errn = encodeNBitUnsignedInteger(stream, 8, 25);
			if(errn == 0) {
				errn = encode_iso1ChargingProfileType(stream, &exiFrag->ChargingProfile );
			}
		} else if ( exiFrag->ChargingProfileEntryMaxNumberOfPhasesInUse_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingProfileEntryMaxNumberOfPhasesInUse) */
			errn = encodeNBitUnsignedInteger(stream, 8, 26);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 2, (uint32_t)(exiFrag->ChargingProfileEntryMaxNumberOfPhasesInUse - 1));
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ChargingProfileEntryMaxPower_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingProfileEntryMaxPower) */
			errn = encodeNBitUnsignedInteger(stream, 8, 27);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->ChargingProfileEntryMaxPower );
			}
		} else if ( exiFrag->ChargingProfileEntryStart_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingProfileEntryStart) */
			errn = encodeNBitUnsignedInteger(stream, 8, 28);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger32(stream, exiFrag->ChargingProfileEntryStart);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ChargingSession_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingSession) */
			errn = encodeNBitUnsignedInteger(stream, 8, 29);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 1, exiFrag->ChargingSession);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ChargingStatusReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingStatusReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 30);
			if(errn == 0) {
				errn = encode_iso1ChargingStatusReqType(stream, &exiFrag->ChargingStatusReq );
			}
		} else if ( exiFrag->ChargingStatusRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingStatusRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 31);
			if(errn == 0) {
				errn = encode_iso1ChargingStatusResType(stream, &exiFrag->ChargingStatusRes );
			}
		} else if ( exiFrag->ConsumptionCost_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ConsumptionCost) */
			errn = encodeNBitUnsignedInteger(stream, 8, 32);
			if(errn == 0) {
				errn = encode_iso1ConsumptionCostType(stream, &exiFrag->ConsumptionCost );
			}
		} else if ( exiFrag->ContractSignatureCertChain_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ContractSignatureCertChain) */
			errn = encodeNBitUnsignedInteger(stream, 8, 33);
			if(errn == 0) {
				errn = encode_iso1CertificateChainType(stream, &exiFrag->ContractSignatureCertChain );
			}
		} else if ( exiFrag->ContractSignatureEncryptedPrivateKey_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ContractSignatureEncryptedPrivateKey) */
			errn = encodeNBitUnsignedInteger(stream, 8, 34);
			if(errn == 0) {
				errn = encode_iso1ContractSignatureEncryptedPrivateKeyType(stream, &exiFrag->ContractSignatureEncryptedPrivateKey );
			}
		} else if ( exiFrag->Cost_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Cost) */
			errn = encodeNBitUnsignedInteger(stream, 8, 35);
			if(errn == 0) {
				errn = encode_iso1CostType(stream, &exiFrag->Cost );
			}
		} else if ( exiFrag->CurrentDemandReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CurrentDemandReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 36);
			if(errn == 0) {
				errn = encode_iso1CurrentDemandReqType(stream, &exiFrag->CurrentDemandReq );
			}
		} else if ( exiFrag->CurrentDemandRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CurrentDemandRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 37);
			if(errn == 0) {
				errn = encode_iso1CurrentDemandResType(stream, &exiFrag->CurrentDemandRes );
			}
		} else if ( exiFrag->DC_EVChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 38);
			if(errn == 0) {
				errn = encode_iso1DC_EVChargeParameterType(stream, &exiFrag->DC_EVChargeParameter );
			}
		} else if ( exiFrag->DC_EVPowerDeliveryParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVPowerDeliveryParameter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 39);
			if(errn == 0) {
				errn = encode_iso1DC_EVPowerDeliveryParameterType(stream, &exiFrag->DC_EVPowerDeliveryParameter );
			}
		} else if ( exiFrag->DC_EVSEChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 40);
			if(errn == 0) {
				errn = encode_iso1DC_EVSEChargeParameterType(stream, &exiFrag->DC_EVSEChargeParameter );
			}
		} else if ( exiFrag->DC_EVSEStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DC_EVSEStatus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 41);
			if(errn == 0) {
				errn = encode_iso1DC_EVSEStatusType(stream, &exiFrag->DC_EVSEStatus );
			}
		} else if ( exiFrag->DC_EVSEStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEStatus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 42);
			if(errn == 0) {
				errn = encode_iso1DC_EVSEStatusType(stream, &exiFrag->DC_EVSEStatus );
			}
		} else if ( exiFrag->DC_EVStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DC_EVStatus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 43);
			if(errn == 0) {
				errn = encode_iso1DC_EVStatusType(stream, &exiFrag->DC_EVStatus );
			}
		} else if ( exiFrag->DC_EVStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVStatus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 44);
			if(errn == 0) {
				errn = encode_iso1DC_EVStatusType(stream, &exiFrag->DC_EVStatus );
			}
		} else if ( exiFrag->DHpublickey_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DHpublickey) */
			errn = encodeNBitUnsignedInteger(stream, 8, 45);
			if(errn == 0) {
				errn = encode_iso1DiffieHellmanPublickeyType(stream, &exiFrag->DHpublickey );
			}
		} else if ( exiFrag->DSAKeyValue_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DSAKeyValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 46);
			if(errn == 0) {
				errn = encode_iso1DSAKeyValueType(stream, &exiFrag->DSAKeyValue );
			}
		} else if ( exiFrag->DepartureTime_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DepartureTime) */
			errn = encodeNBitUnsignedInteger(stream, 8, 47);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger32(stream, exiFrag->DepartureTime);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->DigestMethod_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod) */
			errn = encodeNBitUnsignedInteger(stream, 8, 48);
			if(errn == 0) {
				errn = encode_iso1DigestMethodType(stream, &exiFrag->DigestMethod );
			}
		} else if ( exiFrag->DigestValue_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 49);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->DigestValue.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->DigestValue.bytes, exiFrag->DigestValue.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EAmount_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EAmount) */
			errn = encodeNBitUnsignedInteger(stream, 8, 50);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EAmount );
			}
		} else if ( exiFrag->EPriceLevel_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EPriceLevel) */
			errn = encodeNBitUnsignedInteger(stream, 8, 51);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(exiFrag->EPriceLevel - 0));
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVCCID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVCCID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 52);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_HEX]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->EVCCID.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->EVCCID.bytes, exiFrag->EVCCID.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 53);
			if(errn == 0) {
				errn = encode_iso1EVChargeParameterType(stream, &exiFrag->EVChargeParameter );
			}
		} else if ( exiFrag->EVEnergyCapacity_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVEnergyCapacity) */
			errn = encodeNBitUnsignedInteger(stream, 8, 54);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVEnergyCapacity );
			}
		} else if ( exiFrag->EVEnergyRequest_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVEnergyRequest) */
			errn = encodeNBitUnsignedInteger(stream, 8, 55);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVEnergyRequest );
			}
		} else if ( exiFrag->EVErrorCode_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVErrorCode) */
			errn = encodeNBitUnsignedInteger(stream, 8, 56);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 4, exiFrag->EVErrorCode);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVMaxCurrent_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaxCurrent) */
			errn = encodeNBitUnsignedInteger(stream, 8, 57);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVMaxCurrent );
			}
		} else if ( exiFrag->EVMaxVoltage_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaxVoltage) */
			errn = encodeNBitUnsignedInteger(stream, 8, 58);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVMaxVoltage );
			}
		} else if ( exiFrag->EVMaximumCurrentLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumCurrentLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 59);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVMaximumCurrentLimit );
			}
		} else if ( exiFrag->EVMaximumCurrentLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaximumCurrentLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 60);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVMaximumCurrentLimit );
			}
		} else if ( exiFrag->EVMaximumPowerLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumPowerLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 61);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVMaximumPowerLimit );
			}
		} else if ( exiFrag->EVMaximumPowerLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaximumPowerLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 62);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVMaximumPowerLimit );
			}
		} else if ( exiFrag->EVMaximumVoltageLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumVoltageLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 63);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVMaximumVoltageLimit );
			}
		} else if ( exiFrag->EVMaximumVoltageLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaximumVoltageLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 64);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVMaximumVoltageLimit );
			}
		} else if ( exiFrag->EVMinCurrent_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMinCurrent) */
			errn = encodeNBitUnsignedInteger(stream, 8, 65);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVMinCurrent );
			}
		} else if ( exiFrag->EVPowerDeliveryParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVPowerDeliveryParameter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 66);
			if(errn == 0) {
				errn = encode_iso1EVPowerDeliveryParameterType(stream, &exiFrag->EVPowerDeliveryParameter );
			}
		} else if ( exiFrag->EVRESSSOC_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVRESSSOC) */
			errn = encodeNBitUnsignedInteger(stream, 8, 67);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(exiFrag->EVRESSSOC - 0));
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVReady_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVReady) */
			errn = encodeNBitUnsignedInteger(stream, 8, 68);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->EVReady);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVSEChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 69);
			if(errn == 0) {
				errn = encode_iso1EVSEChargeParameterType(stream, &exiFrag->EVSEChargeParameter );
			}
		} else if ( exiFrag->EVSECurrentLimitAchieved_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSECurrentLimitAchieved) */
			errn = encodeNBitUnsignedInteger(stream, 8, 70);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->EVSECurrentLimitAchieved);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVSECurrentRegulationTolerance_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSECurrentRegulationTolerance) */
			errn = encodeNBitUnsignedInteger(stream, 8, 71);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVSECurrentRegulationTolerance );
			}
		} else if ( exiFrag->EVSEEnergyToBeDelivered_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEEnergyToBeDelivered) */
			errn = encodeNBitUnsignedInteger(stream, 8, 72);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVSEEnergyToBeDelivered );
			}
		} else if ( exiFrag->EVSEID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 73);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->EVSEID.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->EVSEID.characters, exiFrag->EVSEID.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVSEIsolationStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEIsolationStatus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 74);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 3, exiFrag->EVSEIsolationStatus);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVSEMaxCurrent_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaxCurrent) */
			errn = encodeNBitUnsignedInteger(stream, 8, 75);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVSEMaxCurrent );
			}
		} else if ( exiFrag->EVSEMaxCurrent_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaxCurrent) */
			errn = encodeNBitUnsignedInteger(stream, 8, 76);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVSEMaxCurrent );
			}
		} else if ( exiFrag->EVSEMaximumCurrentLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumCurrentLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 77);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVSEMaximumCurrentLimit );
			}
		} else if ( exiFrag->EVSEMaximumCurrentLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaximumCurrentLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 78);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVSEMaximumCurrentLimit );
			}
		} else if ( exiFrag->EVSEMaximumPowerLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumPowerLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 79);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVSEMaximumPowerLimit );
			}
		} else if ( exiFrag->EVSEMaximumPowerLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaximumPowerLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 80);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVSEMaximumPowerLimit );
			}
		} else if ( exiFrag->EVSEMaximumVoltageLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumVoltageLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 81);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVSEMaximumVoltageLimit );
			}
		} else if ( exiFrag->EVSEMaximumVoltageLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaximumVoltageLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 82);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVSEMaximumVoltageLimit );
			}
		} else if ( exiFrag->EVSEMinimumCurrentLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMinimumCurrentLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 83);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVSEMinimumCurrentLimit );
			}
		} else if ( exiFrag->EVSEMinimumVoltageLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMinimumVoltageLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 84);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVSEMinimumVoltageLimit );
			}
		} else if ( exiFrag->EVSENominalVoltage_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSENominalVoltage) */
			errn = encodeNBitUnsignedInteger(stream, 8, 85);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVSENominalVoltage );
			}
		} else if ( exiFrag->EVSENotification_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSENotification) */
			errn = encodeNBitUnsignedInteger(stream, 8, 86);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 2, exiFrag->EVSENotification);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVSEPeakCurrentRipple_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEPeakCurrentRipple) */
			errn = encodeNBitUnsignedInteger(stream, 8, 87);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVSEPeakCurrentRipple );
			}
		} else if ( exiFrag->EVSEPowerLimitAchieved_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEPowerLimitAchieved) */
			errn = encodeNBitUnsignedInteger(stream, 8, 88);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->EVSEPowerLimitAchieved);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVSEPresentCurrent_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEPresentCurrent) */
			errn = encodeNBitUnsignedInteger(stream, 8, 89);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVSEPresentCurrent );
			}
		} else if ( exiFrag->EVSEPresentVoltage_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEPresentVoltage) */
			errn = encodeNBitUnsignedInteger(stream, 8, 90);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVSEPresentVoltage );
			}
		} else if ( exiFrag->EVSEProcessing_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEProcessing) */
			errn = encodeNBitUnsignedInteger(stream, 8, 91);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 2, exiFrag->EVSEProcessing);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVSEStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEStatus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 92);
			if(errn == 0) {
				errn = encode_iso1EVSEStatusType(stream, &exiFrag->EVSEStatus );
			}
		} else if ( exiFrag->EVSEStatusCode_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEStatusCode) */
			errn = encodeNBitUnsignedInteger(stream, 8, 93);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 4, exiFrag->EVSEStatusCode);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVSETimeStamp_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSETimeStamp) */
			errn = encodeNBitUnsignedInteger(stream, 8, 94);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger64(stream, exiFrag->EVSETimeStamp);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVSEVoltageLimitAchieved_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEVoltageLimitAchieved) */
			errn = encodeNBitUnsignedInteger(stream, 8, 95);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->EVSEVoltageLimitAchieved);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVStatus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 96);
			if(errn == 0) {
				errn = encode_iso1EVStatusType(stream, &exiFrag->EVStatus );
			}
		} else if ( exiFrag->EVTargetCurrent_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVTargetCurrent) */
			errn = encodeNBitUnsignedInteger(stream, 8, 97);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVTargetCurrent );
			}
		} else if ( exiFrag->EVTargetVoltage_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVTargetVoltage) */
			errn = encodeNBitUnsignedInteger(stream, 8, 98);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->EVTargetVoltage );
			}
		} else if ( exiFrag->EnergyTransferMode_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EnergyTransferMode) */
			errn = encodeNBitUnsignedInteger(stream, 8, 99);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 3, exiFrag->EnergyTransferMode);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Entry_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Entry) */
			errn = encodeNBitUnsignedInteger(stream, 8, 100);
			if(errn == 0) {
				errn = encode_iso1EntryType(stream, &exiFrag->Entry );
			}
		} else if ( exiFrag->Exponent_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Exponent) */
			errn = encodeNBitUnsignedInteger(stream, 8, 101);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->Exponent.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->Exponent.bytes, exiFrag->Exponent.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->FaultCode_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FaultCode) */
			errn = encodeNBitUnsignedInteger(stream, 8, 102);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 2, exiFrag->FaultCode);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->FaultMsg_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FaultMsg) */
			errn = encodeNBitUnsignedInteger(stream, 8, 103);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->FaultMsg.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->FaultMsg.characters, exiFrag->FaultMsg.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->FreeService_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FreeService) */
			errn = encodeNBitUnsignedInteger(stream, 8, 104);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->FreeService);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->FullSOC_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FullSOC) */
			errn = encodeNBitUnsignedInteger(stream, 8, 105);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(exiFrag->FullSOC - 0));
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->G_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}G) */
			errn = encodeNBitUnsignedInteger(stream, 8, 106);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->G.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->G.bytes, exiFrag->G.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->GenChallenge_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}GenChallenge) */
			errn = encodeNBitUnsignedInteger(stream, 8, 107);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->GenChallenge.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->GenChallenge.bytes, exiFrag->GenChallenge.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->HMACOutputLength_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}HMACOutputLength) */
			errn = encodeNBitUnsignedInteger(stream, 8, 108);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger64(stream, exiFrag->HMACOutputLength);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Header_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDef}Header) */
			errn = encodeNBitUnsignedInteger(stream, 8, 109);
			if(errn == 0) {
				errn = encode_iso1MessageHeaderType(stream, &exiFrag->Header );
			}
		} else if ( exiFrag->J_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}J) */
			errn = encodeNBitUnsignedInteger(stream, 8, 110);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->J.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->J.bytes, exiFrag->J.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->KeyInfo_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyInfo) */
			errn = encodeNBitUnsignedInteger(stream, 8, 111);
			if(errn == 0) {
				errn = encode_iso1KeyInfoType(stream, &exiFrag->KeyInfo );
			}
		} else if ( exiFrag->KeyName_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyName) */
			errn = encodeNBitUnsignedInteger(stream, 8, 112);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->KeyName.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->KeyName.characters, exiFrag->KeyName.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->KeyValue_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 113);
			if(errn == 0) {
				errn = encode_iso1KeyValueType(stream, &exiFrag->KeyValue );
			}
		} else if ( exiFrag->ListOfRootCertificateIDs_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ListOfRootCertificateIDs) */
			errn = encodeNBitUnsignedInteger(stream, 8, 114);
			if(errn == 0) {
				errn = encode_iso1ListOfRootCertificateIDsType(stream, &exiFrag->ListOfRootCertificateIDs );
			}
		} else if ( exiFrag->Manifest_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Manifest) */
			errn = encodeNBitUnsignedInteger(stream, 8, 115);
			if(errn == 0) {
				errn = encode_iso1ManifestType(stream, &exiFrag->Manifest );
			}
		} else if ( exiFrag->MaxEntriesSAScheduleTuple_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MaxEntriesSAScheduleTuple) */
			errn = encodeNBitUnsignedInteger(stream, 8, 116);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, exiFrag->MaxEntriesSAScheduleTuple);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->MeterID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}MeterID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 117);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->MeterID.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->MeterID.characters, exiFrag->MeterID.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->MeterInfo_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeterInfo) */
			errn = encodeNBitUnsignedInteger(stream, 8, 118);
			if(errn == 0) {
				errn = encode_iso1MeterInfoType(stream, &exiFrag->MeterInfo );
			}
		} else if ( exiFrag->MeterReading_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}MeterReading) */
			errn = encodeNBitUnsignedInteger(stream, 8, 119);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger64(stream, exiFrag->MeterReading);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->MeterStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}MeterStatus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 120);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger16(stream, exiFrag->MeterStatus);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->MeteringReceiptReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeteringReceiptReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 121);
			if(errn == 0) {
				errn = encode_iso1MeteringReceiptReqType(stream, &exiFrag->MeteringReceiptReq );
			}
		} else if ( exiFrag->MeteringReceiptRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeteringReceiptRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 122);
			if(errn == 0) {
				errn = encode_iso1MeteringReceiptResType(stream, &exiFrag->MeteringReceiptRes );
			}
		} else if ( exiFrag->MgmtData_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}MgmtData) */
			errn = encodeNBitUnsignedInteger(stream, 8, 123);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->MgmtData.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->MgmtData.characters, exiFrag->MgmtData.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Modulus_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Modulus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 124);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->Modulus.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->Modulus.bytes, exiFrag->Modulus.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Multiplier_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Multiplier) */
			errn = encodeNBitUnsignedInteger(stream, 8, 125);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 3, (uint32_t)(exiFrag->Multiplier + 3));
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Notification_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgHeader}Notification) */
			errn = encodeNBitUnsignedInteger(stream, 8, 126);
			if(errn == 0) {
				errn = encode_iso1NotificationType(stream, &exiFrag->Notification );
			}
		} else if ( exiFrag->NotificationMaxDelay_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}NotificationMaxDelay) */
			errn = encodeNBitUnsignedInteger(stream, 8, 127);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, exiFrag->NotificationMaxDelay);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->NumEPriceLevels_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}NumEPriceLevels) */
			errn = encodeNBitUnsignedInteger(stream, 8, 128);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(exiFrag->NumEPriceLevels - 0));
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->OEMProvisioningCert_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}OEMProvisioningCert) */
			errn = encodeNBitUnsignedInteger(stream, 8, 129);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->OEMProvisioningCert.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->OEMProvisioningCert.bytes, exiFrag->OEMProvisioningCert.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Object_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Object) */
			errn = encodeNBitUnsignedInteger(stream, 8, 130);
			if(errn == 0) {
				errn = encode_iso1ObjectType(stream, &exiFrag->Object );
			}
		} else if ( exiFrag->P_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}P) */
			errn = encodeNBitUnsignedInteger(stream, 8, 131);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->P.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->P.bytes, exiFrag->P.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->PGPData_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPData) */
			errn = encodeNBitUnsignedInteger(stream, 8, 132);
			if(errn == 0) {
				errn = encode_iso1PGPDataType(stream, &exiFrag->PGPData );
			}
		} else if ( exiFrag->PGPKeyID_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPKeyID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 133);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->PGPKeyID.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->PGPKeyID.bytes, exiFrag->PGPKeyID.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->PGPKeyPacket_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPKeyPacket) */
			errn = encodeNBitUnsignedInteger(stream, 8, 134);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->PGPKeyPacket.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->PGPKeyPacket.bytes, exiFrag->PGPKeyPacket.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->PMax_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMax) */
			errn = encodeNBitUnsignedInteger(stream, 8, 135);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->PMax );
			}
		} else if ( exiFrag->PMaxSchedule_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMaxSchedule) */
			errn = encodeNBitUnsignedInteger(stream, 8, 136);
			if(errn == 0) {
				errn = encode_iso1PMaxScheduleType(stream, &exiFrag->PMaxSchedule );
			}
		} else if ( exiFrag->PMaxScheduleEntry_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMaxScheduleEntry) */
			errn = encodeNBitUnsignedInteger(stream, 8, 137);
			if(errn == 0) {
				errn = encode_iso1PMaxScheduleEntryType(stream, &exiFrag->PMaxScheduleEntry );
			}
		} else if ( exiFrag->Parameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 138);
			if(errn == 0) {
				errn = encode_iso1ParameterType(stream, &exiFrag->Parameter );
			}
		} else if ( exiFrag->ParameterSet_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ParameterSet) */
			errn = encodeNBitUnsignedInteger(stream, 8, 139);
			if(errn == 0) {
				errn = encode_iso1ParameterSetType(stream, &exiFrag->ParameterSet );
			}
		} else if ( exiFrag->ParameterSetID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ParameterSetID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 140);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger16(stream, exiFrag->ParameterSetID);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->PaymentDetailsReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentDetailsReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 141);
			if(errn == 0) {
				errn = encode_iso1PaymentDetailsReqType(stream, &exiFrag->PaymentDetailsReq );
			}
		} else if ( exiFrag->PaymentDetailsRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentDetailsRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 142);
			if(errn == 0) {
				errn = encode_iso1PaymentDetailsResType(stream, &exiFrag->PaymentDetailsRes );
			}
		} else if ( exiFrag->PaymentOption_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PaymentOption) */
			errn = encodeNBitUnsignedInteger(stream, 8, 143);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 1, exiFrag->PaymentOption);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->PaymentOptionList_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentOptionList) */
			errn = encodeNBitUnsignedInteger(stream, 8, 144);
			if(errn == 0) {
				errn = encode_iso1PaymentOptionListType(stream, &exiFrag->PaymentOptionList );
			}
		} else if ( exiFrag->PaymentServiceSelectionReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentServiceSelectionReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 145);
			if(errn == 0) {
				errn = encode_iso1PaymentServiceSelectionReqType(stream, &exiFrag->PaymentServiceSelectionReq );
			}
		} else if ( exiFrag->PaymentServiceSelectionRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentServiceSelectionRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 146);
			if(errn == 0) {
				errn = encode_iso1PaymentServiceSelectionResType(stream, &exiFrag->PaymentServiceSelectionRes );
			}
		} else if ( exiFrag->PgenCounter_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PgenCounter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 147);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->PgenCounter.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->PgenCounter.bytes, exiFrag->PgenCounter.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->PowerDeliveryReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PowerDeliveryReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 148);
			if(errn == 0) {
				errn = encode_iso1PowerDeliveryReqType(stream, &exiFrag->PowerDeliveryReq );
			}
		} else if ( exiFrag->PowerDeliveryRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PowerDeliveryRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 149);
			if(errn == 0) {
				errn = encode_iso1PowerDeliveryResType(stream, &exiFrag->PowerDeliveryRes );
			}
		} else if ( exiFrag->PreChargeReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PreChargeReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 150);
			if(errn == 0) {
				errn = encode_iso1PreChargeReqType(stream, &exiFrag->PreChargeReq );
			}
		} else if ( exiFrag->PreChargeRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PreChargeRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 151);
			if(errn == 0) {
				errn = encode_iso1PreChargeResType(stream, &exiFrag->PreChargeRes );
			}
		} else if ( exiFrag->ProfileEntry_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry) */
			errn = encodeNBitUnsignedInteger(stream, 8, 152);
			if(errn == 0) {
				errn = encode_iso1ProfileEntryType(stream, &exiFrag->ProfileEntry );
			}
		} else if ( exiFrag->Q_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Q) */
			errn = encodeNBitUnsignedInteger(stream, 8, 153);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->Q.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->Q.bytes, exiFrag->Q.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->RCD_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RCD) */
			errn = encodeNBitUnsignedInteger(stream, 8, 154);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->RCD);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->RSAKeyValue_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RSAKeyValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 155);
			if(errn == 0) {
				errn = encode_iso1RSAKeyValueType(stream, &exiFrag->RSAKeyValue );
			}
		} else if ( exiFrag->ReceiptRequired_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ReceiptRequired) */
			errn = encodeNBitUnsignedInteger(stream, 8, 156);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->ReceiptRequired);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Reference_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference) */
			errn = encodeNBitUnsignedInteger(stream, 8, 157);
			if(errn == 0) {
				errn = encode_iso1ReferenceType(stream, &exiFrag->Reference );
			}
		} else if ( exiFrag->RelativeTimeInterval_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RelativeTimeInterval) */
			errn = encodeNBitUnsignedInteger(stream, 8, 158);
			if(errn == 0) {
				errn = encode_iso1RelativeTimeIntervalType(stream, &exiFrag->RelativeTimeInterval );
			}
		} else if ( exiFrag->RemainingTimeToBulkSoC_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RemainingTimeToBulkSoC) */
			errn = encodeNBitUnsignedInteger(stream, 8, 159);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->RemainingTimeToBulkSoC );
			}
		} else if ( exiFrag->RemainingTimeToFullSoC_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RemainingTimeToFullSoC) */
			errn = encodeNBitUnsignedInteger(stream, 8, 160);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->RemainingTimeToFullSoC );
			}
		} else if ( exiFrag->RequestedEnergyTransferMode_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RequestedEnergyTransferMode) */
			errn = encodeNBitUnsignedInteger(stream, 8, 161);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 3, exiFrag->RequestedEnergyTransferMode);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ResponseCode_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode) */
			errn = encodeNBitUnsignedInteger(stream, 8, 162);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 5, exiFrag->ResponseCode);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->RetrievalMethod_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RetrievalMethod) */
			errn = encodeNBitUnsignedInteger(stream, 8, 163);
			if(errn == 0) {
				errn = encode_iso1RetrievalMethodType(stream, &exiFrag->RetrievalMethod );
			}
		} else if ( exiFrag->RetryCounter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RetryCounter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 164);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger16(stream, exiFrag->RetryCounter);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->RootCertificateID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RootCertificateID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 165);
			if(errn == 0) {
				errn = encode_iso1X509IssuerSerialType(stream, &exiFrag->RootCertificateID );
			}
		} else if ( exiFrag->SAProvisioningCertificateChain_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SAProvisioningCertificateChain) */
			errn = encodeNBitUnsignedInteger(stream, 8, 166);
			if(errn == 0) {
				errn = encode_iso1CertificateChainType(stream, &exiFrag->SAProvisioningCertificateChain );
			}
		} else if ( exiFrag->SAScheduleList_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleList) */
			errn = encodeNBitUnsignedInteger(stream, 8, 167);
			if(errn == 0) {
				errn = encode_iso1SAScheduleListType(stream, &exiFrag->SAScheduleList );
			}
		} else if ( exiFrag->SAScheduleTuple_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleTuple) */
			errn = encodeNBitUnsignedInteger(stream, 8, 168);
			if(errn == 0) {
				errn = encode_iso1SAScheduleTupleType(stream, &exiFrag->SAScheduleTuple );
			}
		} else if ( exiFrag->SAScheduleTupleID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SAScheduleTupleID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 169);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(exiFrag->SAScheduleTupleID - 1));
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->SAScheduleTupleID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleTupleID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 170);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(exiFrag->SAScheduleTupleID - 1));
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->SASchedules_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SASchedules) */
			errn = encodeNBitUnsignedInteger(stream, 8, 171);
			if(errn == 0) {
				errn = encode_iso1SASchedulesType(stream, &exiFrag->SASchedules );
			}
		} else if ( exiFrag->SPKIData_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKIData) */
			errn = encodeNBitUnsignedInteger(stream, 8, 172);
			if(errn == 0) {
				errn = encode_iso1SPKIDataType(stream, &exiFrag->SPKIData );
			}
		} else if ( exiFrag->SPKISexp_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKISexp) */
			errn = encodeNBitUnsignedInteger(stream, 8, 173);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->SPKISexp.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->SPKISexp.bytes, exiFrag->SPKISexp.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->SalesTariff_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariff) */
			errn = encodeNBitUnsignedInteger(stream, 8, 174);
			if(errn == 0) {
				errn = encode_iso1SalesTariffType(stream, &exiFrag->SalesTariff );
			}
		} else if ( exiFrag->SalesTariffDescription_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffDescription) */
			errn = encodeNBitUnsignedInteger(stream, 8, 175);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->SalesTariffDescription.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->SalesTariffDescription.characters, exiFrag->SalesTariffDescription.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->SalesTariffEntry_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffEntry) */
			errn = encodeNBitUnsignedInteger(stream, 8, 176);
			if(errn == 0) {
				errn = encode_iso1SalesTariffEntryType(stream, &exiFrag->SalesTariffEntry );
			}
		} else if ( exiFrag->SalesTariffID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 177);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(exiFrag->SalesTariffID - 1));
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Seed_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Seed) */
			errn = encodeNBitUnsignedInteger(stream, 8, 178);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->Seed.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->Seed.bytes, exiFrag->Seed.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->SelectedPaymentOption_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SelectedPaymentOption) */
			errn = encodeNBitUnsignedInteger(stream, 8, 179);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 1, exiFrag->SelectedPaymentOption);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->SelectedService_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService) */
			errn = encodeNBitUnsignedInteger(stream, 8, 180);
			if(errn == 0) {
				errn = encode_iso1SelectedServiceType(stream, &exiFrag->SelectedService );
			}
		} else if ( exiFrag->SelectedServiceList_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SelectedServiceList) */
			errn = encodeNBitUnsignedInteger(stream, 8, 181);
			if(errn == 0) {
				errn = encode_iso1SelectedServiceListType(stream, &exiFrag->SelectedServiceList );
			}
		} else if ( exiFrag->Service_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Service) */
			errn = encodeNBitUnsignedInteger(stream, 8, 182);
			if(errn == 0) {
				errn = encode_iso1ServiceType(stream, &exiFrag->Service );
			}
		} else if ( exiFrag->ServiceCategory_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceCategory) */
			errn = encodeNBitUnsignedInteger(stream, 8, 183);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 2, exiFrag->ServiceCategory);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ServiceCategory_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceCategory) */
			errn = encodeNBitUnsignedInteger(stream, 8, 184);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 2, exiFrag->ServiceCategory);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ServiceDetailReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDetailReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 185);
			if(errn == 0) {
				errn = encode_iso1ServiceDetailReqType(stream, &exiFrag->ServiceDetailReq );
			}
		} else if ( exiFrag->ServiceDetailRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDetailRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 186);
			if(errn == 0) {
				errn = encode_iso1ServiceDetailResType(stream, &exiFrag->ServiceDetailRes );
			}
		} else if ( exiFrag->ServiceDiscoveryReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDiscoveryReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 187);
			if(errn == 0) {
				errn = encode_iso1ServiceDiscoveryReqType(stream, &exiFrag->ServiceDiscoveryReq );
			}
		} else if ( exiFrag->ServiceDiscoveryRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDiscoveryRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 188);
			if(errn == 0) {
				errn = encode_iso1ServiceDiscoveryResType(stream, &exiFrag->ServiceDiscoveryRes );
			}
		} else if ( exiFrag->ServiceID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 189);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, exiFrag->ServiceID);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ServiceID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 190);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, exiFrag->ServiceID);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ServiceList_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceList) */
			errn = encodeNBitUnsignedInteger(stream, 8, 191);
			if(errn == 0) {
				errn = encode_iso1ServiceListType(stream, &exiFrag->ServiceList );
			}
		} else if ( exiFrag->ServiceName_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceName) */
			errn = encodeNBitUnsignedInteger(stream, 8, 192);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->ServiceName.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->ServiceName.characters, exiFrag->ServiceName.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ServiceParameterList_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceParameterList) */
			errn = encodeNBitUnsignedInteger(stream, 8, 193);
			if(errn == 0) {
				errn = encode_iso1ServiceParameterListType(stream, &exiFrag->ServiceParameterList );
			}
		} else if ( exiFrag->ServiceScope_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceScope) */
			errn = encodeNBitUnsignedInteger(stream, 8, 194);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->ServiceScope.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->ServiceScope.characters, exiFrag->ServiceScope.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ServiceScope_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceScope) */
			errn = encodeNBitUnsignedInteger(stream, 8, 195);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->ServiceScope.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->ServiceScope.characters, exiFrag->ServiceScope.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->SessionID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 196);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_HEX]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->SessionID.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->SessionID.bytes, exiFrag->SessionID.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->SessionID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgHeader}SessionID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 197);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_HEX]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->SessionID.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->SessionID.bytes, exiFrag->SessionID.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->SessionSetupReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionSetupReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 198);
			if(errn == 0) {
				errn = encode_iso1SessionSetupReqType(stream, &exiFrag->SessionSetupReq );
			}
		} else if ( exiFrag->SessionSetupRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionSetupRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 199);
			if(errn == 0) {
				errn = encode_iso1SessionSetupResType(stream, &exiFrag->SessionSetupRes );
			}
		} else if ( exiFrag->SessionStopReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionStopReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 200);
			if(errn == 0) {
				errn = encode_iso1SessionStopReqType(stream, &exiFrag->SessionStopReq );
			}
		} else if ( exiFrag->SessionStopRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionStopRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 201);
			if(errn == 0) {
				errn = encode_iso1SessionStopResType(stream, &exiFrag->SessionStopRes );
			}
		} else if ( exiFrag->SigMeterReading_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SigMeterReading) */
			errn = encodeNBitUnsignedInteger(stream, 8, 202);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->SigMeterReading.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->SigMeterReading.bytes, exiFrag->SigMeterReading.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Signature_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Signature) */
			errn = encodeNBitUnsignedInteger(stream, 8, 203);
			if(errn == 0) {
				errn = encode_iso1SignatureType(stream, &exiFrag->Signature );
			}
		} else if ( exiFrag->SignatureMethod_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureMethod) */
			errn = encodeNBitUnsignedInteger(stream, 8, 204);
			if(errn == 0) {
				errn = encode_iso1SignatureMethodType(stream, &exiFrag->SignatureMethod );
			}
		} else if ( exiFrag->SignatureProperties_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperties) */
			errn = encodeNBitUnsignedInteger(stream, 8, 205);
			if(errn == 0) {
				errn = encode_iso1SignaturePropertiesType(stream, &exiFrag->SignatureProperties );
			}
		} else if ( exiFrag->SignatureProperty_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperty) */
			errn = encodeNBitUnsignedInteger(stream, 8, 206);
			if(errn == 0) {
				errn = encode_iso1SignaturePropertyType(stream, &exiFrag->SignatureProperty );
			}
		} else if ( exiFrag->SignatureValue_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 207);
			if(errn == 0) {
				errn = encode_iso1SignatureValueType(stream, &exiFrag->SignatureValue );
			}
		} else if ( exiFrag->SignedInfo_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignedInfo) */
			errn = encodeNBitUnsignedInteger(stream, 8, 208);
			if(errn == 0) {
				errn = encode_iso1SignedInfoType(stream, &exiFrag->SignedInfo );
			}
		} else if ( exiFrag->SubCertificates_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SubCertificates) */
			errn = encodeNBitUnsignedInteger(stream, 8, 209);
			if(errn == 0) {
				errn = encode_iso1SubCertificatesType(stream, &exiFrag->SubCertificates );
			}
		} else if ( exiFrag->SupportedEnergyTransferMode_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SupportedEnergyTransferMode) */
			errn = encodeNBitUnsignedInteger(stream, 8, 210);
			if(errn == 0) {
				errn = encode_iso1SupportedEnergyTransferModeType(stream, &exiFrag->SupportedEnergyTransferMode );
			}
		} else if ( exiFrag->TMeter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}TMeter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 211);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger64(stream, exiFrag->TMeter);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->TimeInterval_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}TimeInterval) */
			errn = encodeNBitUnsignedInteger(stream, 8, 212);
			if(errn == 0) {
				errn = encode_iso1IntervalType(stream, &exiFrag->TimeInterval );
			}
		} else if ( exiFrag->Transform_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transform) */
			errn = encodeNBitUnsignedInteger(stream, 8, 213);
			if(errn == 0) {
				errn = encode_iso1TransformType(stream, &exiFrag->Transform );
			}
		} else if ( exiFrag->Transforms_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms) */
			errn = encodeNBitUnsignedInteger(stream, 8, 214);
			if(errn == 0) {
				errn = encode_iso1TransformsType(stream, &exiFrag->Transforms );
			}
		} else if ( exiFrag->Unit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Unit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 215);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 3, exiFrag->Unit);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->V2G_Message_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDef}V2G_Message) */
			errn = encodeNBitUnsignedInteger(stream, 8, 216);
			if(errn == 0) {
				errn = encode_iso1AnonType_V2G_Message(stream, &exiFrag->V2G_Message );
			}
		} else if ( exiFrag->Value_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Value) */
			errn = encodeNBitUnsignedInteger(stream, 8, 217);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger16(stream, exiFrag->Value);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->WeldingDetectionReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}WeldingDetectionReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 218);
			if(errn == 0) {
				errn = encode_iso1WeldingDetectionReqType(stream, &exiFrag->WeldingDetectionReq );
			}
		} else if ( exiFrag->WeldingDetectionRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}WeldingDetectionRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 219);
			if(errn == 0) {
				errn = encode_iso1WeldingDetectionResType(stream, &exiFrag->WeldingDetectionRes );
			}
		} else if ( exiFrag->X509CRL_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509CRL) */
			errn = encodeNBitUnsignedInteger(stream, 8, 220);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->X509CRL.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->X509CRL.bytes, exiFrag->X509CRL.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->X509Certificate_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Certificate) */
			errn = encodeNBitUnsignedInteger(stream, 8, 221);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->X509Certificate.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->X509Certificate.bytes, exiFrag->X509Certificate.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->X509Data_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Data) */
			errn = encodeNBitUnsignedInteger(stream, 8, 222);
			if(errn == 0) {
				errn = encode_iso1X509DataType(stream, &exiFrag->X509Data );
			}
		} else if ( exiFrag->X509IssuerName_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509IssuerName) */
			errn = encodeNBitUnsignedInteger(stream, 8, 223);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->X509IssuerName.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->X509IssuerName.characters, exiFrag->X509IssuerName.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->X509IssuerSerial_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509IssuerSerial) */
			errn = encodeNBitUnsignedInteger(stream, 8, 224);
			if(errn == 0) {
				errn = encode_iso1X509IssuerSerialType(stream, &exiFrag->X509IssuerSerial );
			}
		} else if ( exiFrag->X509SKI_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SKI) */
			errn = encodeNBitUnsignedInteger(stream, 8, 225);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->X509SKI.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->X509SKI.bytes, exiFrag->X509SKI.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->X509SerialNumber_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SerialNumber) */
			errn = encodeNBitUnsignedInteger(stream, 8, 226);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger64(stream, exiFrag->X509SerialNumber);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->X509SubjectName_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SubjectName) */
			errn = encodeNBitUnsignedInteger(stream, 8, 227);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->X509SubjectName.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->X509SubjectName.characters, exiFrag->X509SubjectName.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->XPath_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}XPath) */
			errn = encodeNBitUnsignedInteger(stream, 8, 228);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->XPath.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->XPath.characters, exiFrag->XPath.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Y_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Y) */
			errn = encodeNBitUnsignedInteger(stream, 8, 229);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->Y.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->Y.bytes, exiFrag->Y.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->amount_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}amount) */
			errn = encodeNBitUnsignedInteger(stream, 8, 230);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger32(stream, exiFrag->amount);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->amountMultiplier_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}amountMultiplier) */
			errn = encodeNBitUnsignedInteger(stream, 8, 231);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 3, (uint32_t)(exiFrag->amountMultiplier + 3));
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->boolValue_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}boolValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 232);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->boolValue);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->byteValue_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}byteValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 233);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(exiFrag->byteValue + 128));
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->costKind_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}costKind) */
			errn = encodeNBitUnsignedInteger(stream, 8, 234);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 2, exiFrag->costKind);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->duration_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}duration) */
			errn = encodeNBitUnsignedInteger(stream, 8, 235);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger32(stream, exiFrag->duration);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->eMAID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgBody}eMAID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 236);
			if(errn == 0) {
				errn = encode_iso1EXISchemaInformedElementFragmentGrammar(stream, &exiFrag->eMAID);
			}
		} else if ( exiFrag->intValue_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}intValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 237);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger32(stream, exiFrag->intValue);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->physicalValue_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}physicalValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 238);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->physicalValue );
			}
		} else if ( exiFrag->shortValue_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}shortValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 239);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger16(stream, exiFrag->shortValue);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->start_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}start) */
			errn = encodeNBitUnsignedInteger(stream, 8, 240);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger32(stream, exiFrag->start);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->startValue_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}startValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 241);
			if(errn == 0) {
				errn = encode_iso1PhysicalValueType(stream, &exiFrag->startValue );
			}
		} else if ( exiFrag->stringValue_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}stringValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 242);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->stringValue.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->stringValue.characters, exiFrag->stringValue.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else {
			errn = EXI_ERROR_UNKOWN_EVENT;
		}
	}
	if(errn == 0) {
		/* EndDocument */
		errn = encodeNBitUnsignedInteger(stream, 8, 244);
	}


	if(errn == 0) {
		/* flush any pending bits */
		errn = encodeFinish(stream);
	}

	return errn;
}
#endif /* DEPLOY_ISO1_CODEC_FRAGMENT */


#endif /* DEPLOY_ISO1_CODEC */

#endif

